What makes Strings unique among Java Object types?TopMore ScribblesStrings

Strings

We have already encountered the Java String class:

  1. Can define variables and parameters that reference strings. You can assign values to string names, and you can write methods that return Strings as results. Recall from the unit on GUI items:
       String newLevel = (String)level.getSelectedItem();
    
  2. Can describe strings in programs by placing double quotes around a sequence of characters:
       msg.setText("Got me!");
    
  3. Can glue together strings; can glue together a string and a numeric value to make a new string:
        mouseCount.setText("You clicked " + count + " times.");
    
  4. Can determine if two strings look the same by using the "equals" method. Again, recall from the unit on GUI:
        if (newLevel.equals("Easy")) ...
    
  5. You've been told to always use "equals" to check for equality, rather than "=="

What makes Strings unique among Java Object types?TopMore ScribblesStrings