title: JAVA - Output in mixed order?
body: <p>I'm writing a very the basic program where I put in a string and it prints the word, and the first and last letter of the string. The output should be seen as follows:</p>
  
  <p>word :: Hello</p>
  
  <p>first letter :: H</p>
  
  <p>last letter :: o </p>
  
  <p>However, this is not the case. The letters appear before the word, and well, basically the orders and spacing is crazy! Hopefully someone can help me. Here is the code:</p>
  
  <p>FirstAndLast Class:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import static java.lang.System.*;
  
  public class FirstAndLast
  {
   private String word;
  
   public FirstAndLast(String s)
   {
       word = s;
   }
  
   public void setString(String s)
   {
       word = s;
   }
   
   public String getWord ()
   {
        out.print(word);
        return "";
   }
   
   public String getFirst()
   {
    out.print(word.charAt(0));
       return "";
   }
   
   public String getLast()
   {
       out.print(word.charAt((word.length())-1));
       return "";
   }
  
    public String toString()
    {
        String output="";
     return output;
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The Runner Class:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import static java.lang.System.*;
  
  public class FirstRunner
  {
   public static void main ( String[] args )
   {
    FirstAndLast demo = new FirstAndLast("Hello");
    System.out.println( "Word :: " + demo.getWord() );
    System.out.println( "First letter :: " + demo.getFirst() );
    System.out.println( "Last letter :: " + demo.getLast() );
    
    FirstAndLast bri = new FirstAndLast("Brianna");
    System.out.println( "Word :: " + bri.getWord() );
    System.out.println( "First letter :: " + bri.getFirst() );
    System.out.println( "Last letter :: " + bri.getLast() );
    
   }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Thank you!</p>