第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

需要創(chuàng)建一個person類,請問該如何調(diào)用上面的方法?麻煩各位大神出手相救!

需要創(chuàng)建一個person類,請問該如何調(diào)用上面的方法?麻煩各位大神出手相救!

MMMHUHU 2021-07-20 17:15:57
import java.util.Scanner;class Person{static String name;static int age;static double height;static String your_name;void Person(String name,String your_name,int age,double height){this.name=name;this.age=age;this.height=height;this.your_name=your_name;}public void greeting(){System.out.println("Hello,my name is"+name+",I am"+age+",and I am"+height+"meters tall."); }public void greeting2(String yourName){System.out.println("hello"+your_name+",my name is"+name+",I am"+age+",and I am"+height);}}public class TestPerson{public static void main(String[] args){Person TestPerson=new Person();Scanner in=new Scanner(System.in);System.out.println("There are three attributes defined for a person:name-String, age=integer, and height-cm.");System.out.println("Enter the first person's attributes<on the same line separated by a space>");String name1=in.next();int age1=in.nextInt();double height1=in.nextDouble();System.out.println("Enter the Second person's attributes<on the same line separated by a space>");String name2=in.next();int age2=in.nextInt();double height2=in.nextDouble();String your_name=name1;Person.greeting();//這里開始是錯的}}這是我的程序,題意是 要調(diào)用greeting的方法,輸出 greeting方法內(nèi)的那兩句話, 但是我不知道該怎么樣調(diào)用上面的方法,程序運行到 輸入三個屬性之后就不繼續(xù)下去了。麻煩各位大神出手相救!
查看完整描述

3 回答

?
LEATH

TA貢獻1936條經(jīng)驗 獲得超7個贊

不是Person.greeting()。 應(yīng)該是 TestPerson.greeting();再就是你既然從鍵盤接收了這些值,景應(yīng)該調(diào)用構(gòu)造方法的時候傳進去。

查看完整回答
反對 回復(fù) 2021-07-25
?
滄海一幻覺

TA貢獻1824條經(jīng)驗 獲得超5個贊

Person TestPerson=new Person(); 這個是你new出來的對象,調(diào)用時用TestPerson.greeting();還有個小建議,變量名一般小寫開頭。

查看完整回答
反對 回復(fù) 2021-07-25
  • 3 回答
  • 0 關(guān)注
  • 430 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號