国产三级在线看完整版-内射白嫩大屁股在线播放91-欧美精品国产精品综合-国产精品视频网站一区-一二三四在线观看视频韩国-国产不卡国产不卡国产精品不卡-日本岛国一区二区三区四区-成年人免费在线看片网站-熟女少妇一区二区三区四区

儀器網(wǎng)(yiqi.com)歡迎您!

| 注冊(cè)2 登錄
網(wǎng)站首頁(yè)-資訊-話題-產(chǎn)品-評(píng)測(cè)-品牌庫(kù)-供應(yīng)商-展會(huì)-招標(biāo)-采購(gòu)-知識(shí)-技術(shù)-社區(qū)-資料-方案-產(chǎn)品庫(kù)-視頻

問(wèn)答社區(qū)

測(cè)試類應(yīng)該怎么加?。??

tjgykhulj 2018-11-24 19:18:30 282  瀏覽
  • /*要求新建一個(gè)PersonTest測(cè)試類,對(duì)person類進(jìn)行測(cè)試*/ package com.soft.ght; public class Person拓展 { String name; int age; String address; char sex; int weight; public class PersonTest{ public static void main(String[] args... /*要求新建一個(gè)PersonTest測(cè)試類,對(duì)person類進(jìn)行測(cè)試*/ package com.soft.ght; public class Person拓展 { String name; int age; String address; char sex; int weight; public class PersonTest{ public static void main(String[] args) { // TODO Auto-generated method stub Person p1=new Person();//聲明并實(shí)例化Person類對(duì)象p1 Person p2=new Person();//聲明并實(shí)例化Person類對(duì)象p2 //給p1賦值 p1.name="張三"; p1.age=25; p1.address ="濟(jì)南"; p1.sex ='m'; p1.weight =100; //給p2賦值 p2.name ="李四"; p2.age =30; p2.address ="北京"; p2.sex ='w'; p2.weight =80; System.out.println("名字:"+p1.name +" ,年齡:"+p1.age +" ,家庭住址:"+p1.address +" ,性別:"+p1.sex +" ,體重:"+p1.weight ); System.out.println("名字:"+p2.name +" ,年齡:"+p2.age +" ,家庭住址:"+p2.address +" ,性別:"+p2.sex +" ,體重:"+p2.weight ); } }} 我是這么寫(xiě)的,可是編譯的時(shí)候說(shuō)我錯(cuò)了,非要把public class PersonTest{}改成public static class PersonTest{}或者把public static void main(String[] args) {}改成public void main(String[] args) {}才顯示正確。錯(cuò)誤提示是:The method main cannot be declared static; static methods can only be declared in a static or top level type 這是哪里出了問(wèn)題?我要怎么改呢? 展開(kāi)

參與評(píng)論

全部評(píng)論(0條)

熱門(mén)問(wèn)答

測(cè)試類應(yīng)該怎么加啊??
/*要求新建一個(gè)PersonTest測(cè)試類,對(duì)person類進(jìn)行測(cè)試*/ package com.soft.ght; public class Person拓展 { String name; int age; String address; char sex; int weight; public class PersonTest{ public static void main(String[] args... /*要求新建一個(gè)PersonTest測(cè)試類,對(duì)person類進(jìn)行測(cè)試*/ package com.soft.ght; public class Person拓展 { String name; int age; String address; char sex; int weight; public class PersonTest{ public static void main(String[] args) { // TODO Auto-generated method stub Person p1=new Person();//聲明并實(shí)例化Person類對(duì)象p1 Person p2=new Person();//聲明并實(shí)例化Person類對(duì)象p2 //給p1賦值 p1.name="張三"; p1.age=25; p1.address ="濟(jì)南"; p1.sex ='m'; p1.weight =100; //給p2賦值 p2.name ="李四"; p2.age =30; p2.address ="北京"; p2.sex ='w'; p2.weight =80; System.out.println("名字:"+p1.name +" ,年齡:"+p1.age +" ,家庭住址:"+p1.address +" ,性別:"+p1.sex +" ,體重:"+p1.weight ); System.out.println("名字:"+p2.name +" ,年齡:"+p2.age +" ,家庭住址:"+p2.address +" ,性別:"+p2.sex +" ,體重:"+p2.weight ); } }} 我是這么寫(xiě)的,可是編譯的時(shí)候說(shuō)我錯(cuò)了,非要把public class PersonTest{}改成public static class PersonTest{}或者把public static void main(String[] args) {}改成public void main(String[] args) {}才顯示正確。錯(cuò)誤提示是:The method main cannot be declared static; static methods can only be declared in a static or top level type 這是哪里出了問(wèn)題?我要怎么改呢? 展開(kāi)
2018-11-24 19:18:30 282 0
這個(gè)代碼的測(cè)試類怎么寫(xiě)啊?
public class q { String ys="黃色"; public void fs(){ System.out.println("正在以0.1米/秒的速度向前奔跑"); } public void qs(){ System.out.println("大聲吼叫!"); } public String ball(){ String ball="球"; return ball; ... public class q { String ys="黃色"; public void fs(){ System.out.println("正在以0.1米/秒的速度向前奔跑"); } public void qs(){ System.out.println("大聲吼叫!"); } public String ball(){ String ball="球"; return ball; } } 展開(kāi)
2018-12-08 01:40:55 282 0
java測(cè)試類怎么寫(xiě)測(cè)試類建立
 
2018-11-20 19:56:11 311 0
springboot怎么建測(cè)試類測(cè)試接口
 
2017-10-24 22:15:14 279 1
測(cè)試類怎么傳httpservletrequest
 
2018-11-12 03:41:56 256 0
java測(cè)試類怎么寫(xiě)
 
2018-11-20 00:56:10 390 0
java里面的測(cè)試類是做什么用的?只要類名后面加一個(gè)text就叫測(cè)試類嗎?
 
2016-03-26 22:26:23 264 1
Java的測(cè)試類 怎么寫(xiě)
public class Seller { String name; public Seller() { super(); } public Seller(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { thi... public class Seller { String name; public Seller() { super(); } public Seller(String name) { super(); this.name = name; } public String getName() { return name; } public void setName(String name) { this.name = name; } public void sell1(Excelle excelle){ System.out.println("賣了一輛"+excelle.getType()+"id是"+excelle.getId()); } public void sell2(Regal regal){ System.out.println("賣了一輛"+regal.getType()+"id是"+regal.getId()); } public void sell3(Excelle excelle,int number){ System.out.println("我賣了"+number+"輛車"); for (int i=0;i
2017-04-02 14:39:07 476 1
Myeclipse中怎么編寫(xiě)測(cè)試類
如圖一個(gè)簡(jiǎn)單投票系統(tǒng)的網(wǎng)頁(yè), 編寫(xiě)兩個(gè)JSP,display負(fù)責(zé)顯示投票界面,vote負(fù)責(zé)接受用戶的投票,將對(duì)應(yīng)的教師的得票數(shù)加1,工作完成后再跳轉(zhuǎn)回diyi個(gè)JSP。就是第三點(diǎn),TestDao的代碼如何書(shū)寫(xiě)。
2015-05-12 22:57:23 365 1
testng eclipse 怎么寫(xiě)測(cè)試類
 
2016-03-04 21:07:24 351 1
Android studio怎么創(chuàng)建測(cè)試類
 
2017-09-28 12:18:40 381 1
spring boot 測(cè)試類怎么寫(xiě)
 
2017-03-06 12:15:41 434 1
java junit4測(cè)試類怎么寫(xiě)
 
2017-01-28 22:28:48 497 2
關(guān)于java面向?qū)ο蟮膯卧獪y(cè)試。測(cè)試類應(yīng)該怎么寫(xiě)?具體代碼如下
測(cè)試類應(yīng)該怎么寫(xiě)。 public class Earth { public static void main(String args[]) { Monkey mary=new Monkey("Mary","red",100,120); Food banana=new Food("banana","veg",6); mary.showInfo(); mary.eat(banana); ... 測(cè)試類應(yīng)該怎么寫(xiě)。 public class Earth { public static void main(String args[]) { Monkey mary=new Monkey("Mary","red",100,120); Food banana=new Food("banana","veg",6); mary.showInfo(); mary.eat(banana); mary.piss(); mary.showInfo(); Human helen=new Human("Helen","white",100,170,"Obama"); Food hamberger=new Food("hamberger","meet",3); helen.showInfo(); helen.eat(hamberger); helen.piss(); helen.work(); helen.showInfo(); } } class Monkey { String name; String color; int weight; int height; int tempr; Monkey(String n,String c,int w,int h) { name=n;color=c;weight=w;height=h;tempr=0; } int eat(Food f) { int r; if (f.type.equals("veg")) { r=1*f.quantity; } else if (f.type.equals("meat")) { r=3*f.quantity; } else { r=0; } System.out.println("I'm eatting " + f.name + ", YUMMY!"); weight+=r; height-=r; tempr=r; return r; } int piss() { int r; if (tempr!=0) { Pee mypee=new Pee(tempr); r=mypee.weight; } else { r=0; } weight-=r; return r; } void showInfo() { System.out.println("I'm a " + color + " monkey, my name is: " + name + ", weight " + weight + ", height " + height + "."); } } class Food { String type; String name; int quantity; Food(String t,String n,int q) { type=t;name=n;quantity=q; } void showInfo() { System.out.println(name + ", " + type + ", " + quantity); } } class Pee { int weight; Pee(int w) { weight=w; } } class Human extends Monkey { String fname; Human(String n,String c,int w,int h,String f) { super(n,c,w,h); fname=f; } void work() { weight--; } void showInfo() { System.out.println("I'm a human, my name is: " + name + " " +fname + ", weight " + weight + ", height " + height + "."); } } 展開(kāi)
2013-10-31 00:25:23 391 1
C#編程測(cè)試類和非測(cè)試類
它們有什么區(qū)別,我初學(xué),我想知道到底我知道好似大部分方法放在非測(cè)試類,測(cè)試類應(yīng)該放些什么,感覺(jué)好似有規(guī)定的,因?yàn)槲覄倢W(xué)private 要用SetName初始化,我平時(shí)都是把所有的方法和賦值都放在非測(cè)試類,SetName豈不是廢了嗎。
2013-03-22 07:46:37 407 1
壓力變送器接線應(yīng)該怎么接???
 
2018-06-10 15:41:57 467 1
myeclipse中怎么位某一個(gè)類建立一個(gè)測(cè)試類
 
2016-06-30 16:41:18 326 1
myeclipse中Junit測(cè)試類怎么在里面添加已有類?
 
2018-11-13 12:06:24 327 0

4月突出貢獻(xiàn)榜

推薦主頁(yè)

最新話題