Advertisement
Guest User

Untitled

a guest
May 6th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. class StringDemo {
  2. public static void main (String[] args) {
  3. //The String data type is used to hold a sequence of characters
  4. //We use double quotes to enclose the value of the String
  5. String username = "joseph";
  6. String email = "john.doe@example.com";
  7. System.out.println("username " + username);
  8.  
  9. String firstName = "Joseph";
  10. String lastName = "Kandi";
  11. //We can use the + operator to join String values together
  12. String fullName = firstName +" "+ lastName;
  13. System.out.println("fullName " + fullName);
  14.  
  15. //The String type is an object type
  16. //It comes with several functions or method to operate on its data
  17. //toUpperCase() is a method on the String class.
  18. //We will discuss objects and method later, for now, toUpperCase() makes the value uppercase
  19. String fullNameCapitalized = fullName.toUpperCase();
  20. System.out.println(fullNameCapitalized);
  21.  
  22. //TODO
  23. //Try figure out how to change the name to lower case
  24. //Create a variable with your own first name
  25. //Create a variable last name
  26. //Print your first name in lowercase to the console
  27. //Print your last name value in uppercase
  28. //Join your lowercase first name with your uppercase last name
  29. //Print the result to the console
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement