06 2012 档案

JavaBasic
摘要:package hnust.edu.grammar; //Java中的equals方法和==运算区别 public class EqualsQeustions {public static void main(String[] args) { //比较字符串的问题equals和== String str1 = "string"; String str2 = "string"; System.out.println("equals方法:::"+str1.equals(str2)); System.out.println("== 阅读全文

posted @ 2012-06-19 10:48 云端飘 阅读(466) 评论(0) 推荐(0)

Java中从控制台输入数据的几种常用方法
摘要:一、使用标准输入串System.in//System.in.read()一次只读入一个字节数据,而我们通常要取得一个字符串或一组数字//System.in.read()返回一个整数//必须初始化//int read = 0;char read = '0';System.out.println("输入数据:");try {//read = System.in.read();read = (char) System.in.read();}catch(Exception e){e.printStackTrace();}System.out.println(&quo 阅读全文

posted @ 2012-06-17 23:10 云端飘 阅读(62378) 评论(0) 推荐(4)

浅谈java ”=="
摘要:看来看下面的一段代码: 代码片段1 public static void main(String[] args){Integer a=new Integer(100);Integer b=100;System.out.println(a==b);} 这段代码的输出是什么?相信很多人都会很容易的猜到:false,因为a、b两个对象的地址不同,用“==”比较时是false。恭喜你,答对了。 再看下面的一段代码: 代码片段2 public static void main(final String[] args){Integer a=100;Integer b... 阅读全文

posted @ 2012-06-04 20:21 云端飘 阅读(926) 评论(2) 推荐(2)

导航