Maybe I'm making this more complicated than it needs to, but, when I try write the code, I get firstone
cannot be resolved to a variable.
import java.util.Scanner;
import Diag.Prompts
public class app extends Prompts{
public static void main(String[] args) {
Prompts.Intro();
Scanner uinput = new Scanner(System.in);
System.out.print(firstone);
String a = uinput.nextLine();
System.out.print(secondone);
}
}
I've tried making a object of the prompts class, but no joy.
public class Prompts {
Protected static void Intro() {
System.out.println("text");
}
protected void promptOne(){
String firstone = "some text to be printed";
String secondone = "some more text to be printed";
}
}
Apologies if I haven't explained very clearly, I am still new to Java/coding in general.
Hopefully you can see I am trying to access and print the two variables from another protected class individually, without having to create multiple methods just to print one variable. I know I could just do that or simple create methods with a single System.out
, but I wanted to know if this would work.