Groups
Groups
Sign in
Groups
Groups
姚博士的论坛-教学
Conversations
About
Send feedback
Help
一个关于static的问题和解答
2 views
Skip to first unread message
maomao
unread,
Mar 14, 2008, 11:01:37 AM
3/14/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 姚博士的论坛-教学
静态变量只能是类的成员变量。局部变量无法定义为静态的
2008-03-14
--------------------------------------------------------------------------------
Dr. Yao Yu
--------------------------------------------------------------------------------
发件人: zhaohonglianvip
发送时间: 2008-03-14 10:00:24
收件人: yaoyu
抄送:
主题: java
姚老师:
你好!
我不明白为什么在一个方法内不可以定义静态变量?例如:
public static void main(String[] args)
{
System.out.println("Inside main()");
//Cups.p1.f(99);
Cups x=new Cups();
static int x;// 编译的时候提示非法的表达式开始
x.p1.f(33);
}
void f(int maker)
{
static int x=1;//编译的时候提示非法的表达式开始
System.out.println("f"+maker);
}
Reply all
Reply to author
Forward
0 new messages