Topic: 如何给变量输入数据?如C语言里的scanf |
Print this page |
1.如何给变量输入数据?如C语言里的scanf | Copy to clipboard |
Posted by: wangchen223 Posted on: 2006-07-08 15:09 如何给变量输入数据?如C语言里的scanf |
2.Re:如何给变量输入数据?如C语言里的scanf [Re: wangchen223] | Copy to clipboard |
Posted by: Jcat Posted on: 2006-07-08 18:54 byte[] temp=new byte[128]; 我想问的是,当输入超过128个byte以后,怎么办? |
3.Re:如何给变量输入数据?如C语言里的scanf [Re: wangchen223] | Copy to clipboard |
Posted by: mtdhwgij Posted on: 2006-07-08 20:32 wangchen223 wrote: import javax.swing.JOptionPane; ..... {String m; m=JOptionPane.showInputDialog; ..... } |
4.Re:如何给变量输入数据?如C语言里的scanf [Re: Jcat] | Copy to clipboard |
Posted by: mtdhwgij Posted on: 2006-07-08 20:36 Jcat wrote:byte[] temp=new byte[128]; 这个貌似要进行异常处理。 |
5.Re:如何给变量输入数据?如C语言里的scanf [Re: mtdhwgij] | Copy to clipboard |
Posted by: sunjavaduke Posted on: 2006-07-08 21:59 mtdhwgij wrote: That will be ok! and you can use other method to transfer the format! For example,you input 25,and you want an variable of int type,so you can use: int number=Integer.parseInt(m); |
6.Re:如何给变量输入数据?如C语言里的scanf [Re: wangchen223] | Copy to clipboard |
Posted by: wangchen223 Posted on: 2006-07-09 15:59 public class lianxi2 { public static void main(String[]args) { byte[] temp=new byte[128]; System.in.read(temp); System.out.println(new String(temp)); } } 有错误呀 C:\Downloads\gerenlianxi>javac lianxi2.java lianxi2.java:6: unreported exception java.io.IOException; must be caught or dec ared to be thrown System.in.read(temp); ^ 1 error 1 error |
7.Re:如何给变量输入数据?如C语言里的scanf [Re: wangchen223] | Copy to clipboard |
Posted by: joshuajava Posted on: 2006-07-10 00:11 引用:unreported exception java.io.IOException; must be caught or dec ared to be thrown IO流要加入异常抛出捕获的。。。。 public static void main(String[]args) { try { byte[] temp=new byte[128]; System.in.read(temp); System.out.println(new String(temp)); }catch(Exception e){ e.printstackTrace(); } } |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |