What's Here?
- Members: 244,291
- Replies: 693,155
- Topics: 113,164
- Snippets: 3,863
- Tutorials: 935
- Total Online: 948
- Members: 75
- Guests: 873
|
An example of some string manipulation techniques.
|
Submitted By: Jayman
|
|
Rating:
  
|
|
Views: 4,062 |
Language: Java
|
|
Last Modified: July 29, 2006 |
Snippet
import java.lang.String;
import javax.swing.JOptionPane;
public class StringExercise1
{
public static void main (String[] args )
{
textString = JOptionPane. showInputDialog("Enter a string:");
totalString(textString);
convLowerCase(textString);
replaceLetters(textString);
convUpperCase(textString);
}
public static void totalString (String text )
{
System. out. println("The length of the string " + text + " is "
+ text.length());
}
public static void convLowerCase (String text )
{
System. out. println("Here it is in lower case "
+ text.toLowerCase());
}
public static void replaceLetters (String text )
{
System. out. println("Here it is with the a and z swapped "
+ text.replace('a','z'));
}
public static void convUpperCase (String text )
{
System. out. println("Here it is in upper case "
+ text.toUpperCase());
}
}
Copy & Paste
|
|
|
Be Social
Reference Sheets
Bye Bye Ads
Monthly Drawing
Top Contributors
Top 10 Kudos This Month
|