Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Assignment2Question6{
- public static Scanner input = new Scanner(System.in);
- public static void main(String[] args) {
- getString();
- }
- public static void getString(){
- System.out.println("Continually enter values, to stop input an empty"
- + "string.");
- int i = 0;
- String[] value = new String[1];
- do{
- value[i] = input.nextLine();
- System.out.println("\r");
- i++;
- if(i == value.length){
- value = resize(value, i+1);
- }
- }while(value[i] != null);
- for(int m = 0; m < value.length - 1; m++)
- System.out.println(value[m] + " ");
- }
- public static String[] resize(String[] array, int newSize){
- array = new String[newSize];
- return array;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement