Here's the program in which I am getting an error:
// import Scanner Class import 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);
}
}
these are the errors that I am getting:
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)
Your error is in this line:
System.out.println("your id is:",+a);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.