Skip to content

Instantly share code, notes, and snippets.

@Phonbopit
Last active December 18, 2015 17:49
Show Gist options
  • Save Phonbopit/5821519 to your computer and use it in GitHub Desktop.
Save Phonbopit/5821519 to your computer and use it in GitHub Desktop.
package main.com.devsharing.loop;
public class LoopExample1 {
public static void main(String[] args) {
int num = 2;
for(int j=1; j<=12; j++) {
System.out.println(num + " x " + j + " = " + num*j);
}
}
}
public class LoopExample2 {
public static void main(String[] args) {
int num = 12;
for(int i = 2; i <= num; i++) {
for(int j = 1; j <= 12; j++) {
System.out.println(i + " x " + j + " = " + i*j);
}
System.out.print("\n");
}
}
}
import java.util.Scanner;
public class LoopExample3 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("เลือกจำนวนสูตรคูณ : ");
int num = scan.nextInt();
for(int i = 2; i <= num; i++) {
for(int j = 1; j <= 12; j++) {
System.out.println(i + " x " + j + " = " + i*j);
}
System.out.print("\n");
}
scan.close();
}
}
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
System.out.println("Why can't change indent size ?");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment