Topic: 方法中能声明static 变量吗? |
Print this page |
1.方法中能声明static 变量吗? | Copy to clipboard |
Posted by: AchillesA Posted on: 2004-08-05 17:22
错误的原因是不是static value不能在方法中声明啊? |
2.Re:方法中能声明static 变量吗? [Re: AchillesA] | Copy to clipboard |
Posted by: kam Posted on: 2004-08-05 21:12 YES |
3.Re:方法中能声明static 变量吗? [Re: AchillesA] | Copy to clipboard |
Posted by: bsspirit Posted on: 2004-08-07 10:59 不能在方法内声名static 变量。 也不可以在方法的内部类中,声名static 变量 。 但可以在内部静态类中,声名static 变量。 public class StaticTest1{ static int b = 20; public static int go(){ return b; } static class work{ static int c = 30; } public static void main(String[] args){ int t = StaticTest1.go(); int m = StaticTest1.work.c; System.out.println(t+" "+m); } } RESULT: 20 30 |
4.Re:方法中能声明static 变量吗? [Re: AchillesA] | Copy to clipboard |
Posted by: AchillesA Posted on: 2004-08-08 17:22 thanks !! |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |