I tried to output multiplication table in Java

While I was returning home on New Year's Day, I heard that Koji's niece was studying multiplication tables for homework, and thought, "Let's write in Java," so I wrote it.

Multiplication table with for statement


  for (int col = 1; col <= 9; col++) {
    for (int row = 1; row <= 9; row++) {
      System.out.println(col + " × " + row + " = " + (col * row));
    }
  }

This alone is not interesting, so I wrote it with the Stream API I am studying.

Multiplication table with Stream API


  IntStream.rangeClosed(1, 9)
    .forEach(col -> IntStream.rangeClosed(1, 9)
      .forEach(row -> System.out.println(col + " × " + row + " = " + (col * row)))
    );

I understood "how to write a simple for statement with Stream API" and "nesting of for statement and nesting of Stream API".

Recommended Posts

I tried to output multiplication table in Java
# 2 [Note] I tried to calculate multiplication tables in Java.
I tried to implement deep learning in Java
I tried to create Alexa skill in Java
I tried metaprogramming in Java
I tried to implement Firebase push notification in Java
I tried to create a Clova skill in Java
I tried to make a login function in Java
I tried to implement the Euclidean algorithm in Java
~ I tried to learn functional programming in Java now ~
I tried to find out what changed in Java 9
I tried using JWT in Java
I tried to summarize Java learning (1)
I tried to summarize Java 8 now
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I tried to convert a string to a LocalDate type in Java
I tried using Dapr in Java to facilitate microservice development
I tried to make a client of RESAS-API in Java
I tried to summarize Java lambda expressions
I tried setting Java beginners to use shortcut keys in eclipse
I tried to make Basic authentication with Java
I tried to implement polymorphic related in Nogizaka.
I want to send an email in Java.
I tried to organize the session in Rails
java I tried to break a simple block
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (PowerMockito edition)
rsync4j --I want to touch rsync in Java.
I tried to build Micra mackerel in 1 hour!
I tried to make a talk application in Java using AI "A3RT"
I tried to develop an application in 2 languages
I tried to break a block with java (1)
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (Javassist second decoction)
Even in Java, I want to output true with a == 1 && a == 2 && a == 3 (black magic edition)
I tried Java Lambda input / output type ~ POJO edition ~
I tried to organize the cases used in programming
I want to do something like "cls" in Java
I tried to implement TCP / IP + BIO with JAVA
How to input / output IBM mainframe files in Java?
I tried using Google Cloud Vision API in Java
I tried to operate SQS using AWS Java SDK
I want to use ES2015 in Java too! → (´ ・ ω ・ `)
I tried Java Lambda input / output type ~ Stream version ~
I tried to implement Stalin sort with Java Collector
[Java] I tried to implement Yahoo API product search
I tried using an extended for statement in Java
I want to stop snake case in table definition
I tried passing Java Silver in 2 weeks without knowing Java
Gzip-compress byte array in Java and output to file
Java adds table to PDF
I made roulette in Java.
I tried Drools (Java, InputStream)
Output multiplication table with Stream
I tried using Java REPL
I tried to verify yum-cron
I tried to explain Effective Java 3rd edition "almost all chapters" in "easy-to-read Japanese".
I tried to make an application in 3 months from inexperienced
I tried to create a java8 development environment with Chocolatey
I tried to modernize a Java EE application with OpenShift.
[JDBC] I tried to access the SQLite3 database from Java.
I tried to summarize the basics of kotlin and java
Object-oriented child !? I tried Deep Learning in Java (trial edition)