Mr A Mr A - 1 year ago 83
Java Question

How to Run private class same class

Can figure why it won't allow me to run the

because it's private even though I know I can run it from from same class. Is there a way to do this without using reflective API?

This is the error

Error:(10, 9) java: cannot find symbol
symbol: class displayMainMenu
location: class LoginPrototype


import java.util.*;

public class LoginPrototype {

public static void main(String[] args) {

ArrayList<Credentials> allUsers = new ArrayList<Credentials>();
displayMainMenu mainMenu = new displayMenu();

private void displayMainMenu() {
int input;
do {
System.out.println("Menu Options");
System.out.println("[1] Login");
System.out.println("[2] Register");
System.out.println("[0] Quit");//5 Displaying Main Menu Options
Scanner sc = new Scanner(;
input = sc.nextInt();

if (input > 2) {
System.out.println("Please enter a value of [0] - [2]");
else if (input == 1){
else if (input == 2){
else if (input == 0){
System.out.println("Thank you. bye.");
}while(input >= 2);

Answer Source
 displayMainMenu mainMenu = new displayMenu();

This line does not make sense. You are treating the function like an object. You should just call the function itself: displayMainMenu();

But make the function public.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download