标题:各位大佬能帮忙看看是哪里不对吗,报错了好多,万分感谢!
只看楼主
JN_
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2021-12-2
结帖率:0
已结贴  问题点数:20 回复次数:1 
各位大佬能帮忙看看是哪里不对吗,报错了好多,万分感谢!
package contact;

import java.util.Scanner;
public class HelloWorld
{
   
    public static void main(String[] args)
    {
        Scanner put =new Scanner(System.in);
        Person P1=new Person();
        
        P1.name="Tom";
        P1.age = 18;
        P1.sex = 1;        
        P1.study();
   
    }
     
}

public class Person ()
{
        String name;
        int age;
        int sex;
        
        public void study()
        {
            System.out.println("studying");
        }
        public void showAge()
        {
            System.out.println("age:"+age);
        }
        public int addAge(int i)
        {
            age+=i;
            return age;
        }
}
搜索更多相关主题的帖子: System int void public age 
2022-02-15 19:11
娱乐
Rank: 2
等 级:论坛游民
帖 子:9
专家分:20
注 册:2020-2-16
得分:20 
把class Person后面的括号去掉,
Person类的public去掉
2022-02-19 15:39



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-508362-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022297 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved