Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Assignment2Question6{
  3. public static Scanner input = new Scanner(System.in);
  4. public static void main(String[] args) {
  5. getString();
  6. }
  7. public static void getString(){
  8. System.out.println("Continually enter values, to stop input an empty"
  9. + "string.");
  10. int i = 0;
  11. String[] value = new String[1];
  12. do{
  13. value[i] = input.nextLine();
  14. System.out.println("\r");
  15. i++;
  16. if(i == value.length){
  17. value = resize(value, i+1);
  18. }
  19. }while(value[i] != null);
  20. for(int m = 0; m < value.length - 1; m++)
  21. System.out.println(value[m] + " ");
  22. }
  23.  
  24. public static String[] resize(String[] array, int newSize){
  25. array = new String[newSize];
  26. return array;
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement