首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

变量有关问题

2012-02-25 
变量问题public class Chp2Basic{public static void main(String[] args){byte a8char chashort b

变量问题
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=falsej=falsem=-9x=8y=4*/
[解决办法]
这个变量没用到 警告而已
[解决办法]
警告正常。。。不用的变量就不要声明就行了
[解决办法]
写完代码要多检查,这种警告貌似点了以后可以自动帮你修复的

热点排行
Bad Request.