簡體   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