JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Java 新手區  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 vb的語法轉成java格式
maxims





發文: 6
積分: 0
於 2008-04-19 15:18 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
有一段vb的語法是利用struct的方法宣告, 我想轉成java該怎麼寫?
1
2
3
4
5
6
7
Private Type saveinfo   
     id As String  
     name As String  
     status As String  
End Type   
  
Dim info(1 To 50) As saveinfo   

因為java沒有struct, 所以用class的方法, 但是會出錯, 請問該如何寫?


reply to postreply to post
作者 Re:vb的語法轉成java格式 [Re:maxims]
honeyaaa





發文: 159
積分: 0
於 2008-04-19 18:45 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
怎麼個錯法?
提出你的想法來和大家討論?^^


reply to postreply to post
努力,是成功唯一的途徑。
作者 Re:vb的語法轉成java格式 [Re:honeyaaa]
maxims





發文: 6
積分: 0
於 2008-04-19 20:15 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
honeyaaa wrote:
怎麼個錯法?
提出你的想法來和大家討論?^^


1
2
3
4
5
6
7
class Saveinfo{   
     String id;   
     String name;   
     String status;   
 }   
  
Saveinfo data = new Saveinfo();   


主要是vb的 "Dim info(1 To 50) As saveinfo" 這一段, 不知道該怎麼表示它?
不知道該怎麼把 Saveinfo data = new Saveinfo();
像vb一樣宣告成陣列.


reply to postreply to post
作者 Re:vb的語法轉成java格式 [Re:maxims]
honeyaaa





發文: 159
積分: 0
於 2008-04-19 20:41 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
maxims wrote:
1
2
3
4
5
6
7
class Saveinfo{   
     String id;   
     String name;   
     String status;   
 }   
  
Saveinfo data = new Saveinfo();   


主要是vb的 "Dim info(1 To 50) As saveinfo" 這一段, 不知道該怎麼表示它?
不知道該怎麼把 Saveinfo data = new Saveinfo();
像vb一樣宣告成陣列.


1
2
3
Saveinfo[] datas = new Saveinfo[50];
for(int i=0;i<datas.length;i++)
    datas[i] = new Saveinfo() ; 


@@


reply to postreply to post
努力,是成功唯一的途徑。
作者 Re:vb的語法轉成java格式 [Re:honeyaaa]
maxims





發文: 6
積分: 0
於 2008-04-19 22:17 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
honeyaaa wrote:
1
2
3
Saveinfo[] datas = new Saveinfo[50];
for(int i=0;i<datas.length;i++)
    datas[i] = new Saveinfo() ; 


@@


嗯, 成功了, 就是少了
for(int i=0;i<datas.length;i++)
datas[i] = new Saveinfo() ;

可以請問為什麼要加這個嗎?


reply to postreply to post
作者 Re:vb的語法轉成java格式 [Re:maxims]
maxims





發文: 6
積分: 0
於 2008-04-20 08:51 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
如果這邊這段程式~
1
Saveinfo[] datas = new Saveinfo[50];

請問如果不要用陣列, 而想用vector有辦法嗎?因為陣列得設大小, 或這有其他較好的方法?


reply to postreply to post
» JWorld@TW »  Java 新手區

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8