Primitive data types and Strings

Primitive data types:

More information in primitive data types, in pages 44-46 of your book.

String

This is not a primitive data type, It is an object, it is special and different object. It is a set of char (primitive data types) put together. There are plenty of uses for strings. We will use it for our first assignment.

 

Our first JAVA program

 import java.io.*;

class FirstProgram{
  public static void main (String[] arg){
     String name = "Blanca";
     System.out.println(name);
  } //closes the main method
} //closes the class

String methods

What methods does the String class provide?
What methods does the String class provide?

Follow the form: objectReference.method-name(arguments)

METHOD RETURNS ARGUMENTS
toUpperCase reference to a String object none
toLowerCase reference to a String object none
length an integer number none
trim reference to a String object none
concat reference to a String object reference to a String object
substring reference to a String object a number (position to start)
substring reference to a String object two numbers (positions to start and end)