ur mails...got a lot...how?
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 1 楼,分 1 页, 当前显示第 1 页 : 本帖树形列表 : 刷新 : 返回上一页
<<始页  [1]  末页>>
作者:小蹦 (等级:10 - 炉火纯青,发帖:3962) 发表:2004-06-30 13:00:58  楼主  关注此帖
问几个java问题What will be the output on compiling/running the following code? public class MyThread implements Runnable { String myString = "Yes "; public void run() { this.myString = "No "; } public static void main(String[] args) { MyThread t = new MyThread(); new Thread(t).start(); for (int i=0; i < 10; i++) System.out.print(t.myString); } } 问题是,myString 不是public的,为什么main()最后一行不会报错呢? 我把main()移到另一个class中,也能run,都有点学糊涂了我 :P 第二个问题 public class Static { static { int x = 5; } static int x,y; public static void main(String args[]) { x--; myMethod(); System.out.println(x + y + ++x); } public static void myMethod() { y = x++ + ++x; } } 这里有两个static, 一个是static{ int x = 5;} 另一个是static int x; 如何拿到在那个static{}中的x? 还想知道前者有什么用吗? 多谢!!
ur mails...got a lot...how?
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版所有回复从这里展开收起列表
论坛导航 -> 华新鲜事 -> 求学狮城 | 返回上一页 | 本主题共有 1 篇文章,分 1 页, 当前显示第 1 页 | 回到顶部
<<始页  [1]  末页>>

请登录后回复:帐号   密码