Hey guys sorry this is a pretty long question but I cannot call printPASSInfo() to another class using pm.printPASSInfo(). pm is the name I named the class that the method I am trying to call is in. I can call the method pm.printSSNInfo just fine I do not understand what is going wrong. I am sorry this is probably confusing and very long but please try to help. Thanks guys! Heres my code:
import java.util.Scanner;
public class Prog1Methods_FA11 {
String ssn, pw, phoneNumber,line;
Scanner input = new Scanner (System.in);
boolean validPW_Length = true,
validPW_Symbols = true,
validPW_enough_Digits = true;
boolean validSSN_Digits = true,
validSSN_Format = true,
validSSN_Length = true;
boolean validPhone_Symbols = true,
validPhone_Format = true,
validPhone_Length = true;
public Prog1Methods_FA11() {
}
// you may insert a method here to display password status
public void printPASSInfo(){
System.out.println("\t Password Information");
System.out.println("The Password:\t" + pw);
System.out.println("Password Lrngth:\t" + validPW_Length);
System.out.println("Password has minimum number of digits:\t" + validPW_enough_Digits);
System.out.println("Password has correct symbols:\t" + validPW_Symbols);
}
// you may insert a method here to display the phone number status
}
and here is where I am trying to call it:
case 2: System.out.println("Enter a password witha atleast 8 characters and atleast 2 numbers:\t");
pw = input.nextLine();
pm.readAndVerifyPASS(pw);
pm.printPASSInfo();
break;
and the comile error:
MySkeletonProgram1_FA11.java:53: cannot find symbol
symbol : method printPASSInfo()
location: class Prog1Methods_FA11
pm.printPASSInfo();
^
1 error
Where I declare pm object:
public class MySkeletonProgram1_FA11{
public static void main(String[] args)throws Exception {
// Declarations
Scanner scan = new Scanner(System.in);
Scanner input = new Scanner (System.in);
Prog1Methods_FA11 pm = new Prog1Methods_FA11();
I’m not sure how well I understood your question.
I just tried to reproduce the error.
So, what I’ve done.
1. File MySkeletonProgram1_FA11.java
2. File Prog1Methods_FA11.java
3. I’ve put both files in the same directory.
4. Compilation command
Compilation finished successfully without errors and warnings.
Does it work for you? If the answer is “No”, then I think it’s a problem with your JDK. Otherwise you might want to provide additional details. What are you doing differently?