Java的简单程序,为什么有红叉,刚学不懂,求帮忙了~

2025-05-12 05:53:30
推荐回答(4个)
回答(1):


package xom.number.demo;//设一个包名字 这里随便设置为“xom.number.demo”


import java.lang.System;

import java.lang.String;


public class number {

public static void main(String[] args) {//导包 import java.lang.String;

int a, b, c, d;

int n = 1687;

a = n % 10;

b = n / 10 % 10;

c = n / 100 % 10;

d = n / 1000;

System.out.println("n的每位数字是a=" + a + " b=" + b + " c=" + c + " d=" + d);

//导包 import java.lang.System;

}


}

//此处去掉一个“}”号

回答(2):

你的工程不是一个java工程,你重新新建一个java工程,然后把代码copy过去就是了。现在报错是因为必要的jar包没有导入哈。eclipse新建java项目步骤:file-new-java project

回答(3):

最下面多了一个大括号,删掉。
包名最好不要省略。点击(缺省包),按F2修改名字。
类名(number),最好首字母大写
ps:Ctrl+s保存

回答(4):

多了个}?