title: How to make a navigation system between views with java
body: <p>I have been stuck with an issue for quite a while.</p>
  
  <p>I am making a simple educational Java software and i didn't find any example of navigation systeme to switch between pages.
  What i mean is that i am making a "core" exposing an API and differents user interfaces including command line interface(cli), graphical user interface(gui), web interface and probably an android app.
  My issue is about the CLI but should probably be applied to the GUI too: how would you switch from a page to another?</p>
  
  <p>I have tried to make it such as an enum implementing an interface including a function that instantiate the view. This way a view returns the specific enum of the view to display. The enum is then executed to make the view. But is really seems inefficient and complicated even tho it is scalable.</p>
  
  <p>Here is a simple representation of what i am aiming at.</p>
  
  <pre><code>Launcher
  -&gt; System.out.println("welcome");
  -&gt; go to Authenticate
  
  Authenticate
  -&gt; System.out.println("1: sign in, 2: login")
  -&gt; if(input == 1) go to SignIn
  -&gt; else go to LogIn
  
  SignIn
  -&gt; System.out.println("enter username and password")
  -&gt; username = input
  -&gt; password = input
  -&gt; new User(username, password)
  -&gt; go to Authenticate
  
  LogIn
  -&gt; print("enter username")
  -&gt; go to Etc...
  </code></pre>
  
  <p>Shouldn't the navigation be centralized to avoid memory loss if a view is called by another? Shouldn't a "menu" centralize all the view calls to make the code readable?</p>
  
  <p>Might be a dumb question but i haven't found an answer and i would really like one...</p>