Implementation idea: We can implement it through double for loops. The outer loop controls the number of rows and the inner loop controls the columns, so that the multiplication table can be printed out.
(Recommended tutorial: java entry program)
Implementation code:
public class Demo { public static void main(String[] args) { for (int i = 1; i <10; i++) { for (int j = 1; j <= i; j++) { System.out.print(j + "*" + i + "=" + i * j + " "); } System.out.println(); } } }
Output result:
Recommended related video tutorials: java video tutorial
The above is the detailed content of How to output multiplication table in java. For more information, please follow other related articles on the PHP Chinese website!