title: Passing value of a string in an array to a method in java?
body: <p>thank you for taking the time to read this. Sorry if my question is dumb, I tried searching but couldn't quite figure out why I'm having this problem. I was trying to test some code for another application, but I'm having issues. Perhaps I just don't understand arrays properly.</p>
  
  <p>I have a method named halfStepUp in a class named Transpose that, for testing purposes, should return "c#" if given "c" and "d#" if given "d". This is the code:</p>
  
  <pre><code>public class Transpose{
      public static String halfStepUp(String note){
          String n = null;
          if (note == "c") n = "c#";
          if (note == "d") n = "d"#;
          return n;
      }   
  }
  </code></pre>
  
  <p>I have the following code in my main method:</p>
  
  <pre><code>String [] scale = new String[2];
  scale[0] = "c";
  scale[1] = "d";
  
  System.out.println(Transpose.halfStepUp(scale[0]));
  </code></pre>
  
  <p>This prints "null." What am I doing wrong? 
  I know the method works because if I use</p>
  
  <pre><code>System.out.println(Transpose.halfStepUp("c"));
  </code></pre>
  
  <p>It works fine. The solution is probably embarrassingly easy but I couldn't find a good way to word it when searching for help.
  Thanks again for reading, and any answers are greatly appreciated!</p>