I'm new to java programming and Stackoverflow and I had a question. I'm trying to display text assigned to variables and when I try to run the program is says that non-static variables can't be referenced from static content. Here's my code:
public class VariableTesting {
String firstName = "Tom"; //String first, last,
char middleInitial = 'B';
String lastName = firstName;
public static void main(String[] args) {
variable();
}
public static void variable(){
System.out.println(lastName + "," + firstName + "," + middleInitial);
}
}
I appreciate any and all help. Thanks