My code:
package a1;
import java.util.Scanner;
public class MySweetProgram {
public static void main(String[] args) {
//create an instance of the User class
//User user1 = new User();
//giving a value to properties for user1
//user1.firstName = "Kodaik";
//user1.lastName = "Andrzej";
//call the method printUserName
//System.out.println(user1.printUserName());
String password = "1234";
System.out.println("Guess the password: ");
//create the scanner object
Scanner scan = new Scanner(System.in);
String guess = scan.nextLine();
}
}
**
This is the error that I am getting:**
Error: Unable to initialize main class a1.MySweetProgram in module Hello
Caused by: java.lang.NoClassDefFoundError: [LString;
I tried deleting the package statement: package a1. I also tried opening the “medule-info.java Hello” and running the program, but I got the error: Error:
Unable to initialize main class a1.MySweetProgram in module Hello
Caused by: java.lang.NoClassDefFoundError: [LString;
A Brave search says that I may be missing a ‘dependency” which I don’t know what it is.
I am expecting the code to just accept a password that is typed into the console.
Druiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1