package AD1; //private/default/protected/public //private用于同一个类 //default用于同一个类/包 //protected用于同一个类/包/子类 //public用于同一个类/包/子类/所有类 public class text1 { int id=1001; String name="yang"; String pwd="123456"; public void sleep(){ System.out.println("睡觉觉!!"); } } class text5 extends text1{ public static void main(String[] args) { text1 s1=new text1(); System.out.println(s1.id); } }
提问:class tex1中default修饰的变量如 int id=1001; 为什么可以在其子类class text5中调用,显示结果为1001? default修饰的不是不包含子类中调用么?
老师,笔记本上的insert如何用,alt+insert,笔记本上不太好用,查了一下说按住Fn会转换,使用了还是不行。
老师为什么我的paintthread是红的呀
public class TestConstant {
public static void main(String[] args){
final double pi = 3.14;
//pi = 3.1415; //无法为常量再次分配值
final int MAX_SPEED = 120; //常量的命名:全用大写字母,单词之间下划线隔开
int r = 4;
double area = PI*r*r;
double circle = 2*PI*r;
System.out.println("面积是:"+area);
System.out.println("周长是:"+circle);
}
IDE eg:IDEA eclipse 只起到了编写的作用是吗?
编译和解释实际上是安装的jdk的作用是吗?
如果不安装jdkIDEA eclipse能好使吗?
TestConstants.java:10: 错误: 编码 GBK 的不可映射字符 (0xAF) System.out.println("闈㈢Н鏄?:"+area);老师这个问题怎么解决?
跟上老师一步一步地安装JDK,但是测试安装后还是这样。
/** * 测试循环语句中的break * @author liuyanfeng * */ public class TestBreak { public static void main(String[] args) { //生成0-100随机数,直到生成88为止,停止循环 System.out.println("##########生成0-100随机数,直到生成88为止,停止循环##########"); int total=0;//计数 System.out.println("Begin"); while(true) { total++; int i=(int)Math.round(100*Math.random()); /*math.round();是对参数四舍五入; * 相当于1+(int) */ if(i==80) { break; } } System.out.println("Game over,used"+total+"times"); System.out.println("##########生成0-100随机数,直到生成88为止,停止循环##########"); int total01=0;//计数 int count=0; System.out.println("Begin"); for(int i=0;i<=100;i=(int)Math.round(100*Math.random())) { total01++; System.out.print(i+"、"); count++; //打印10次换一行 if(count%10==0) { System.out.println(); } if(i==80) { break; } } System.out.println(); System.out.println("Game over,used"+total01+"times"); } }
运行结果:
问题:第二种方法中,for循环自创一种迭代方式,不是i++,是i取随机数,这种行不行?运行起来,能实现这个循环的功能,只是随机循环;这种方式能不能用?
老师请问一下,在第二行时,n自增了一次,从2开始,m也自增了一次,为什么还是从1开始呢
{ ([] args) { [] ={}[] ={}[] ={}[] ={}[] ={}[] = Object[][]= []= []=[]=[]=(=<.++){ (=<[].++){ ..print(} } } () { } () { .= } () { } () { .= } () { } () { .= } () { } () { .= } () { } () { .= }
老师 为什么里面红色部分报错
cn.itbaizhanTestLoop2 { (String[]args){ (i = i <= i++) { (j = j < ij++) { System..print()} (j = ij <= j++) { System..print(i + + j + + i * j + )} System..println()} } }
\t\t是什么意思
为什么没有提供破解版的idea,自己去找好麻烦啊
老师好,想问一下这里键盘为什么不能同时控制两个飞机的移动
src.rar
提问: 这里为什么会报错,有什么方法可以解决?
老师麻烦帮我看看是哪里出问题 关于继承的
public class TestOverride { public static void main(String[] args) { Vehicle v1 = new Vehicle(); v1.run(); Horse h1 = new Horse(); h1.run(); } } class Vehicle{ public void run(){ System.out.println("这是父类的run()方法"); } public Vehicle getVehicle(){ System.out.println("给Vehicle一个交通工具"); return null; } } class Horse extends Vehicle{ public void run(){ run(); } }
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637