Ramirez_RD

Samson_PreDefined

Aug 18th, 2025
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class Samson_PreDefined {
  3.     static void Run() {
  4.         String myName = "Angel";
  5.         String myAddress = "Makati City";
  6.         String myBday = "1st of October 2004";
  7.         String food = "Mango & Donut";
  8.         String greet = "Hello, I'm " + myName + "\nBut my friends call me \" Ange!\"";
  9.         String sur = "samson";
  10.  
  11.         String output = "";
  12.         output += greet + "\n";
  13.         output += "There are " + myName.length() + " letters in my Name.\n";
  14.         output += "Address: " + myAddress + "\n";
  15.         output += "UpperCase: " + myAddress.toUpperCase() + "\n";
  16.         output += "LowerCase: " + myAddress.toLowerCase() + "\n";
  17.         output += "Favorite Food: " +food+"\n";
  18.         output += "Substring 0-5 in food: " + food.substring(0, 5) + "\n";
  19.         output += "Substring 5-end in food: " + food.substring(8) + "\n";
  20.         output += "Index of 'O' in myBday: " + myBday.indexOf('O') + "\n";
  21.         output += "Index of 'of' in myBday: " + myBday.indexOf("of") + "\n";
  22.         output += "Replace: " + sur + " -> " + sur.replace('s', 'S') + "\n";
  23.         //message box
  24.         JOptionPane.showMessageDialog(null, output,
  25.                 "Program Output", JOptionPane.INFORMATION_MESSAGE);
  26.     }
  27.     public static void main(String[] args) {
  28.         Run();
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment