Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- Scanner sc = new Scanner(System.in);
- public void print()
- {
- String a = "";
- System.out.println("What would you like to display on the console?");
- a = sc.nextLine();
- System.out.println("\"" + a + "\"");
- }
- public void loop()
- {
- String a = "";
- int count = 1;
- System.out.println("What would you like to display on the console 10 times in a row?");
- a = sc.nextLine();
- for (int i = 0; i < 10; i++)
- {
- System.out.println(count + "." + " \"" + a + "\"");
- count++;
- }
- }
- public void arr()
- {
- int number = 0;
- int count = 1;
- System.out.println("How many entries would you like in your String array?");
- number = sc.nextInt();
- String[] a = new String[number];
- System.out.println("What are the values you'd like to display?");
- for (int i = 0; i < number; i++)
- {
- a[i] = sc.nextLine();
- System.out.println(count + "." + " \"" + a + "\"");
- count++;
- }
- }
- public void methods()
- {
- // trim()
- String input = " some thing ";
- System.out.println("TRIM");
- System.out.println("Before -->" + input + "<--");
- System.out.println("After -->" + input.trim() + "<--");
- }
- public static void main(String args[])
- {
- }
- }
- ------------------------------------------------------------------------------------------------------------------------------
- public class Tester
- {
- public static void main(String args[])
- {
- Main m = new Main();
- m.print();
- System.out.println("=======================================================================");
- m.loop();
- System.out.println("=======================================================================");
- m.arr();
- System.out.println("=======================================================================");
- m.methods();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement