fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner scan = new Scanner(System.in);
  13. String str="";
  14. String exit="exit";
  15.  
  16. System.out.println("Please enter some words : ");
  17. while(true){
  18. str=scan.next();
  19. if(str.equalsIgnoreCase(exit)) break;
  20. System.out.println(str);
  21. }
  22.  
  23. scan.nextLine(); // consume rest of the string after exit word
  24. System.out.println("Please enter a sentnce : ");
  25. String sentence1 = scan.nextLine(); // get sentence
  26.  
  27. System.out.println("the word you entered is : " + sentence1);
  28. }
  29. }
Success #stdin #stdout 0.06s 2184192KB
stdin
era era food food correct correct sss sss exit
example sentence
stdout
Please enter some words : 
era
era
food
food
correct
correct
sss
sss
Please enter a sentnce : 
the word you entered is : example sentence