If/else java

Apr 26, 2020

In this post, we will talk about the conditional handing in java. Let's start with the basics first.

What is a condition?

Condition is a state of something, if that specific state occurs, we say that the condition is fulfilled for that specific state.

Let's see how conditions look in Java:

Before we actually start looking into the code, we expect you know how to write basic Java code. If you do not know, relax, we've got you covered. Check out our starter guide on Java and then continue with this post.

Hello World in Java!
This post explains how to write a ‘Hello world’ program in Java programminglanguage. Why do we start with Hello world program always? > You may say this is a tradition now before starting learning any language. Photo by Maximilian Weisbecker[https://unsplash.com/@maximilianweisbecker?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit…
Hello world in java,

Okay, now that you're geared up, let's jump into the code.

Class Condition {
	public static void main(String[] args) {
    	String text = "We are learning about if conditions.";
        if ( text.length() > 10 ) {
        	System.out.println("Size of text is greater than 10.");
        }
    }
}
If condition in Java.

This above snippet explains if the size of 'text' variable is greater than 10, we print a line.


Thanks, this post will be updated.