繁体   English   中英

为什么我收到以下代码的错误;

[英]why am i getting the error of below code ;

这是我收到错误的程序:

// 导入扫描仪 Class 导入 java.util.Scanner;

// creating ClassStudent1
class ClassStudent1 {

    // creating instance variable for ClassStudent1 class
    int id;
    String name;

}

// creating another class in which main() will be present
class Student2{

    // creating main() method
    public static void main(String[] args) {

        // creating Scanner Class object
        Scanner sc=new Scanner(System.in);

        // creating ClassStudent1 object
        ClassStudent stu = new ClassStudent();

        // asigning value to the ClassStudent1 object stu
        stu.name="jay";
        stu.id=1023;

        // printing the value which is asign to the object
        System.out.println(stu.id);
        System.out.println(stu.name);

        // asigning value to the Scanner Class object
        System.out.println("enter your name");
        String b=sc.nextLine();

        System.out.println("enter your id");
        int a=sc.nextInt();

        stu.id = a;
        stu.name = b;

       System.out.println("your id is:",a);
      //  System.out.println("your name is:",b);

        System.out.println(a);
        System.out.println(b);
    }
}

这些是我得到的错误:

java: no suitable method found for println(java.lang.String,int)
    method java.io.PrintStream.println() is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(boolean) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(char) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(int) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(long) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(float) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(double) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(char[]) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(java.lang.String) is not applicable
      (actual and formal argument lists differ in length)
    method java.io.PrintStream.println(java.lang.Object) is not applicable
      (actual and formal argument lists differ in length)

您的错误在这一行:

System.out.println("your id is:",+a);

查看此链接以了解如何使用 println

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM