史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   程式語言討論區 (http://forum.slime.com.tw/f76.html)
-   -   JAVA的疑問 (http://forum.slime.com.tw/thread201997.html)

leowang 2007-04-04 08:26 PM

JAVA的疑問
 
PHP 語法:

public cstu(String s1,String s2,int m,int f,int c)
   {
      
id=s1;
      
name=s2;
      
mid=m;
      
finl=f;   
      
common=c;   
   }
.
.
.
.
.
.


 public static 
void main(String args[])throws IOException
   
{
          
int i,n;
        
int a[];
        
String str;
        
BufferedReader buf;
        
a=new int[5];
        
buf= new BufferedReader(new InputStreamReader(System.in));
        
        for (
i=0;i<5;i++)
        {
        
System.out.print("輸入資料:");
        
str=buf.readLine();
        
n=Integer.parseInt(str); //字串轉為數字
        
a[i]=n//把數字存入陣列
        
}
         
cstu stu=new cstu();<----------------//這邊要怎修改阿
         
stu.show();
   }


cstu stu=new cstu(d12312,Leo,95,85,95);
怎麼改成可用輸入方式來輸入資料
cstu stu=new cstu();<----------------//這邊要怎修改阿

snoopy 2007-04-05 02:38 AM

System.out.print("輸入:");
args1 = buf.readLine();

System.out.print("輸入:");
args2 = buf.readLine();

System.out.print("輸入:");
args3 = Integer.parseInt(buf.readLine());

System.out.print("輸入:");
args4 = Integer.parseInt(buf.readLine());

System.out.print("輸入:");
args5 = Integer.parseInt(buf.readLine());

cstu stu=new cstu(args1,args2,args3,args4,args5);

leowang 2007-04-05 09:45 AM

非常感謝大大的解答
我把它改成用迴圈陣列來寫了


所有時間均為台北時間。現在的時間是 04:07 AM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2024, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1