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初学者,,,还没怎么入门,大哥们是怎么成长的呢? 我花时间搞清这些小问题有意义吗???? 谢谢大家了!!
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库的描述应该算相当通透的。
@.@||~
看来这是比较深的内容了! 多谢大哥指路~~