title: How can I use the string from other method?
body: <pre><code>package lab07_PrinceRalambomanarivo;
  
  import java.awt.Color;
  import javax.swing.*;
  import java.util.Random;
  
  public class ESPGame {
      private String chosenColor;
  
  public Color chooseColor(int input)
  {
      Color color;
  
      switch(input)
      {
          case 1:
              color = Color.BLUE;
              chosenColor = "blue";
          break;
          case 2:
              color = Color.YELLOW;
              chosenColor = "yellow";
          break;
          case 3:
              color = Color.RED;
              chosenColor = "red";
          break;
          case 4:
              color = Color.GREEN;
              chosenColor = "green";
          break;
          case 5:
              color = Color.ORANGE;
              chosenColor = "orange";
          break;
          case 6:
              color = Color.CYAN;
              chosenColor = "cyan";
          break;
          default:
              color = Color.BLACK;
              chosenColor = "black";
          break;
      }
      return color;
  }
  public void showColor(Color color)
  {
      JFrame frame = new JFrame("Guess this color");
      frame.setSize(200,200);
      frame.setLocation(300,300);
      JPanel panel = new JPanel();
      panel.setBackground(color);
      frame.add(panel);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
  public void guessColor()
  {}}
  </code></pre>
  
  <p>How can I get the value of the chosenColor inside the method chooseColor() inside the method guessColor().</p>