日期:2014-05-20  浏览次数:20668 次

变量问题
public class Chp2Basic 
{

public static void main(String[] args) 
{
byte a=8;  
char ch='a';
short b=16;
int c=32;
long d=64;
float e=32.0f;
double f=64.00;
boolean g=true,h=false,i,j;
String str="hello!";
i=g&&h; //g与h需是boolean型
j=g&h;
int m=~a; //m可以是int long ..型
int x=32>>>2; //移位运算 类型得是int 。。。
int y=b>>>2;
System.out.println("i="+i);
System.out.println("j="+j);
System.out.println("m="+m);
System.out.println("x="+x);
System.out.println("y="+y);
}
}


这代码在MyEclipse 软件里运行 有显示 the local variable ch is never read 等好几个这样 这是什么意思?


------解决方案--------------------
i=false
j=false
m=-9
x=8
y=4
------解决方案--------------------
那是警告 表示哪些变量都没有用到 无所谓的
------解决方案--------------------
the local variable ch is never read 

这句 就是说 char ch='a';这个变量 下面都没有用到
------解决方案--------------------
说的是你的定义的ch没有使用,是个警告。
------解决方案--------------------
(⊙o⊙)… 问题没看清 汗·~~
the local variable ch is never read 这是IDE 善意的提醒~~
------解决方案--------------------
Java code

/*
Outout:
i=false
j=false
m=-9
x=8
y=4
*/

------解决方案--------------------
这个变量没用到 警告而已
------解决方案--------------------
警告正常。。。不用的变量就不要声明就行了
------解决方案--------------------
写完代码要多检查,这种警告貌似点了以后可以自动帮你修复的