Search Java Code Snippets

  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.

#Java - Code Snippets for '#Scanner.nextInt' - 1 code snippet(s) found

 Sample 1. Write a method to input 10 numbers and then print the sum.

public void calculateSum() {
   Scanner scanner=new Scanner(;
   int sum=0;
   for(int counter=1;counter<=10;counter++)

   System.out.println("The sum is: "+sum);

   Like      Feedback     scanner  for loop  scanner.nextInt   input numbers and print sum

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner