Skip to content

Instantly share code, notes, and snippets.

@olegrewko
Created April 24, 2020 14:10
Show Gist options
  • Save olegrewko/8cacdfc0f36abf0170e497e2631ccb4d to your computer and use it in GitHub Desktop.
Save olegrewko/8cacdfc0f36abf0170e497e2631ccb4d to your computer and use it in GitHub Desktop.
TableC
package IgorDolgov;
import java.util.ArrayList;
public class TableC{
public static void main (String[] args) {
ArrayList t1 = multiline(2, 6);
for (int i = 0; i < t1.size(); i++) {
System.out.println(t1.get(i));
}
System.out.println("-----------------------------------------------------------");
ArrayList t2 = multiline(6, 10);
for (int i = 0; i < t2.size(); i++) {
System.out.println(t2.get(i));
}
}
public static ArrayList multiline (int from, int to) {
ArrayList<String> table = new ArrayList<>();
for (int i = 1; i < 10; i++) {
String s = " ";
for (int j = from; j < to; j++) {
s += (Integer.toString(j) + " * " + Integer.toString(i) + " = " + Integer.toString(i * j) + "\t\t");
}
table.add(s);
}
return table;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment