Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class Samson_PreDefined {
- static void Run() {
- String myName = "Angel";
- String myAddress = "Makati City";
- String myBday = "1st of October 2004";
- String food = "Mango & Donut";
- String greet = "Hello, I'm " + myName + "\nBut my friends call me \" Ange!\"";
- String sur = "samson";
- String output = "";
- output += greet + "\n";
- output += "There are " + myName.length() + " letters in my Name.\n";
- output += "Address: " + myAddress + "\n";
- output += "UpperCase: " + myAddress.toUpperCase() + "\n";
- output += "LowerCase: " + myAddress.toLowerCase() + "\n";
- output += "Favorite Food: " +food+"\n";
- output += "Substring 0-5 in food: " + food.substring(0, 5) + "\n";
- output += "Substring 5-end in food: " + food.substring(8) + "\n";
- output += "Index of 'O' in myBday: " + myBday.indexOf('O') + "\n";
- output += "Index of 'of' in myBday: " + myBday.indexOf("of") + "\n";
- output += "Replace: " + sur + " -> " + sur.replace('s', 'S') + "\n";
- //message box
- JOptionPane.showMessageDialog(null, output,
- "Program Output", JOptionPane.INFORMATION_MESSAGE);
- }
- public static void main(String[] args) {
- Run();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment