# Printing and Loops

Now that you know how to print, you can really demonstrate the power of loops.

You will be given two numbers, `a` and `b`. Print `a` (the first number) `b` times. For example, if given `3` and `5`, you should print `3` 5 times: `33333`.

Print each case on one line. Remember to use `System.out.print` to print without adding a newline.

Note: For more practice, try solving printing multiplication.

### Challenge

Print each number `a` `b` times.

Alternatively, you can try out Learneroo before signing up.

• #### TechLord256

How many possible solutions are there to this challenge?

• #### Learneroo

There are many possible ways, but one way is particularly straightforward.

• #### Marlon Buella

This code fragment also works:
`for(int x = 1; x <= b; x++)`

• #### Greg

yo keesh can anyone post the answer...

• import java.util.Scanner;
public class PrintLoop
{
public static void main(String[] args)
{
int a;
int b;
Scanner input = new Scanner(System.in);

• #### Gary

for(int c = b; c > 0; c = c - 1)

• #### Harshi Athukorala

import java.util.Scanner;

public class Loop1{
public static void main(String args[]){
Scanner input1 = new Scanner(System.in);
System.out.println("Enter First number !");

• #### rajni dound

import java.util.Scanner;
public class Main(){
public static void main(String[] args){
int a=2;
int b=4;
for(int i=1;i<=b;i=i+1){
System.out.print(a);
}
}
}

• BUG!