class aaa
{
public static void main (String args[])
{
int x=0;
try
{
x=System.in.read();
}
catch
(Exception e){}
System.out.println(x*6);
}
}
如上,输入一个字符,然后*6。
我输入2,结果显示是300,把2对应的ASC码50去乘了6。
请问大家,有什么办法输入2就用2去*6呢??? 小弟是JAVA初学者,,,还没怎么入门,大哥们是怎么成长的呢? 我花时间搞清这些小问题有意义吗???? 谢谢大家了!!
{
public static void main (String args[])
{
int x=0;
try
{
x=System.in.read();
}
catch
(Exception e){}
System.out.println(x*6);
}
}
如上,输入一个字符,然后*6。
我输入2,结果显示是300,把2对应的ASC码50去乘了6。
请问大家,有什么办法输入2就用2去*6呢??? 小弟是JAVA初学者,,,还没怎么入门,大哥们是怎么成长的呢? 我花时间搞清这些小问题有意义吗???? 谢谢大家了!!
解决方案 »
- 俄罗斯方块 有关空指针的问题,求大侠,急!!!
- 为什么JOptionPane.showmessagedialog会弹出两次一样的对话框来?
- 请问,1,2,3,4,5,7,9,10,11,12,17这样一个数列,我要把它显示成1-7,9-12,17这样的一个形式,如何处理?
- j2se学到什么程度可以学j2ee?高手请指点
- 求一个JAVA的正则表达式
- JTable某行使用黄色字体,如何实现?
- j2se+access考试系统
- 请问大家JBoss的稳定性和效率如何?
- 我在网上当了一个jbuilder5 ,慢的要死,这是怎没回事???
- 用java发送邮件
- 如何创建、读取一个zip文件
- 如何使用指定密匙DES加密数据?
class aaa
{
public static void main (String args[])
{
String str = null;
int x;
try
{
BufferedReader in = new BufferedReader(new InputStream(System.in));
str = in.readLine();
x = Integer.parseInt(str);
}
catch
(Exception e){}
System.out.println(x*6);
}
} 就可以了
不过,,第10行编译错误? 是不是哪里打错啦??
PS:这个内容有点深奥,,,看来要到以后才能理解.
new BufferedReader(
new InputStreamReader(
System.in));//错误出在new InputStream,改为new InputStreamReader@.@||~
class aaa
{
public static void main (String args[])
{
int x=0;
try{
x=System.in.read();
}catch(Exception e){}
System.out.println(Integer.parseInt(x)*6));
}
}
class aaa
{
public static void main (String args[])
{
String str = null;
int x=1;
try
{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
str = in.readLine();
x = Integer.parseInt(str);
}
catch
(Exception e){}
System.out.println(x*6);
}
}
大哥这样就对了哈,要注意细心点撒!!呵呵
{
public static void main (String args[])
{
int x=0;
try{
x=System.in.read();
}catch(Exception e)
{
System.out.println((Integer.parseInt(x))*6));
}
}
}
public static void main( String[] args ) throws IOException {
BufferedReader in =
new BufferedReader(
new InputStreamReader(
System.in));
try {
System.out.print( "Please input a number: " );
int x = Integer.parseInt( in.readLine() );
System.out.println( "The result is (x * 6): " + (x * 6) );
} catch( IOException e ) {}
}
} /// @.@||~以上代码经测试通过,均真实可用,上海市公证局公证(哈哈)
另:Java IO 系统是个结构相当复杂的结构设计,如果要深入JAVA,就必须好好掌握整个IO体系
Integer.parseInt( String s ),可以看出,接收一个String对象,而不是Byte对象。在JAVA IO设计体系中分为Stream && Char流这两个派别,使用前一种方法,正是将一个Stream流转换成char流,从而获得一个String对象,对IO设计的具体分析应该不算基础了吧可能比较进阶了,可以参考《Think in java》,其中对IO库的描述应该算相当通透的。
@.@||~
看来这是比较深的内容了! 多谢大哥指路~~