We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Java
  3. Introduction
  4. Java Loops I
  5. Discussions

Java Loops I

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 991 Discussions, By:

votes

Please Login in order to post a comment

  • [deleted] 5 years ago+ 59 comments

    As a C programmer

    public class Solution {
    
        public static void main(String[] args) {
            Scanner in = new Scanner(System.in);
            int N = in.nextInt();
    
            for(int i = 1; i <= 10; i++){
    
                System.out.printf("%d x %d = %d%n", N, i, N*i);
            }
        }
    }
    
    132|
    Permalink
    View more Comments..
  • Emmanuelmireku15
    4 years ago+ 5 comments

    This is what I got but after reading the discussions, I a lot of people using the printf method. But this code here will do the same job. This code is in Java 8.

    import java.io.*;
    import java.util.*;
    
    public class Solution {
    
        public static void main(String[] args) {
            /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
            Scanner sc = new Scanner(System.in);
            int input = sc.nextInt();
            sc.close();
            
            for(int i = 1; i <= 10; i++){
                int answer = input*i;
                System.out.println(input + " x " + i + " = " + answer);
            }
        }
    }
    
    19|
    Permalink
    View more Comments..
  • spacetaco94
    5 years ago+ 0 comments

    for(int i=0; i<10; i++){

    System.out.printf("%d x %d = %d\n", N, (i+1), (N*(i+1)));
    

    }

    6|
    Permalink
  • uvkrishnasai
    4 years ago+ 0 comments

    IntStream.rangeClosed(1,10).forEachOrdered(i -> System.out.println(String.format("%d x %d = %d", N, i, i*N)));

    5|
    Permalink
  • chase2learns
    6 months ago+ 0 comments

    Here you'll get all the solutions of Java with explaination https://www.chase2learn.com/hackerrank-java-programming-solutions

  • Java - Introduction

  • Welcome to Java!
  • Java Stdin and Stdout I
  • Java If Else
  • Java Stdin and Stdout II
  • Java Output Formatting
  • Java loops I
  • Java loops II
  • Java Static Initializer Block
  • Java Date and Time
  • Java Currency Formatting
  • Java - Strings

  • Java String Introduction
  • Java Substring
  • Java Substring Comparison
  • Java String Reverse
  • Java Anagrams
  • Java String Tokens
  • Java Regex
  • Java Regex 2
  • Valid username Regular Expression
  • Java - Object Oriented Programming

  • Java Interface
  • Java Method Overriding
  • Java Method Overriding2
  • Java Instanceof keyword
  • Java Iterator
  • Java Exception Handling

  • Java Exception Handling (Try-catch)
  • Java Exception Handling
  • Java Advanced

  • Java Varargs Simple Addition
  • Java Reflection Attribute
  • Can you Access?
  • Prime Checker
  • Java Factory Pattern
  • Java Singleton Pattern
  • Java Visitor Patterns
  • Java Annotations
  • Covariant Return Types
  • Java Lambda Expression
  • Java MD5
  • Java SHA-256
1|
Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature