fork download
  1. import java.util.Scanner;
  2. class Jtutorial1 {
  3. public static void main(String args[]){
  4. Scanner input = new Scanner(System.in);
  5. /*
  6.   int total=0, countDown=0;
  7.   double average=0;
  8.  
  9.   do{
  10.   System.out.println("Enter a number between 1 and 1000: ");
  11.   countDown=input.nextInt();
  12.   }while(countDown < 1 || countDown > 1000);
  13.  
  14.  
  15.   for(int i=1; i<= countDown; i++){
  16.   total += i;
  17.   System.out.println(i);
  18.   }
  19.  
  20.   average = total / (double)countDown;
  21.  
  22.  
  23.   System.out.println("The total of all the numbers between 1 and "+countDown+ " is "+total+" and the average is: "+average);
  24.  
  25.  
  26.   //(int)x, (long)x,
  27.   * /
  28.   */
  29. String hello="Hello World";
  30.  
  31. System.out.println("The length of the string hello is: " +hello.length()+ " And contains the words / characters: "+hello );
  32.  
  33.  
  34. }//end main
  35. }//end class
Success #stdin #stdout 0.06s 213888KB
stdin
Standard input is empty
stdout
The length of the string hello is: 11 And contains the words / characters: Hello World