Chat LIVE With Programming Experts! There Are 23 Online Right Now...

 

Code Snippets

  

Java Source Code


Welcome to Dream.In.Code
Become a Java Expert!

Join 244,291 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 948 people online right now. Registration is fast and FREE... Join Now!





Simple String Manipulation

An example of some string manipulation techniques.

Submitted By: Jayman
Actions:
Rating:
Views: 4,062

Language: Java

Last Modified: July 29, 2006

Snippet


  1. import java.lang.String;
  2. import javax.swing.JOptionPane;
  3.  
  4. public class StringExercise1
  5. {
  6.      public static void main(String[] args)
  7.           {
  8.                String textString;
  9.                              
  10.                textString = JOptionPane.showInputDialog("Enter a string:");
  11.                
  12.                              
  13.                totalString(textString);
  14.                convLowerCase(textString);
  15.                replaceLetters(textString);
  16.                convUpperCase(textString);
  17.                
  18.                System.out.println();
  19.                System.exit( 0 );     
  20.           } 
  21.          
  22.           public static void totalString(String text)
  23.           {
  24.                System.out.println("The length of the string " + text + " is "
  25.                + text.length());
  26.           }
  27.          
  28.           public static void convLowerCase(String text)
  29.           {
  30.                System.out.println("Here it is in lower case "
  31.                + text.toLowerCase());
  32.           }
  33.          
  34.           public static void replaceLetters(String text)
  35.           {
  36.                System.out.println("Here it is with the a and z swapped "
  37.                + text.replace('a','z'));
  38.           }
  39.          
  40.           public static void convUpperCase(String text)
  41.           {
  42.                System.out.println("Here it is in upper case "
  43.                + text.toUpperCase());
  44.           }
  45. }

Copy & Paste


Comments


There are currently no comments for this snippet. Be the first to comment!

Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month