• Home
  • Java
    • Java Basics
  • Kafka
    • Producer
  • AWS
  • GoLang
  • About Me
mjpric3@gmail.com
Curriculum Vitae

The Code Standard

  • Home
  • Java
    • Java Basics
  • Kafka
    • Producer
  • AWS
  • GoLang
  • About Me

Conditional Statements

Basics

Conditional Statements are a core part of programming and everyday life. When writing a program will have to tell the computer to execute some statements based on present conditions. Example below:

Picture, you’re lost in the woods and you come to a fork in the road. You have a decision to make. Do you go left or right? If you go left then you have 2 more miles to go before finding shelter (Mountain Lions live that way), Else if you go right you will have 8 more miles before finding shelter (Bunnies live that way).

pubic class Woods {

public String navigateTheWoods(String direction){
   
   // if the value inside the if-statement is true go left
   if(direction.equals("Left")){ 

      System.out.println("You have 2 miles left. Beware of the 
      Mountain Lions!!!");

   }// else if the value inside the else-if is true go right
   else if(direction.equals("Right")){

      System.out.println("Oh no 8 more miles left. Bunnies are so 
      cute");

   }
} 

}

You also might be interested in

Best Languages To Begin With

Dec 22, 2018

So what programming language to start with? There are many[...]

Inheritance

Dec 22, 2018

is one of the four pillars of Java. Its purpose[...]

What Is A Class

Dec 22, 2018

What is a Java Class? There are two kinds of[...]

Recent Posts

  • Producer
  • Interfaces
  • Abstraction
  • Polymorphism
  • Conditional Statements

Categories

  • Basics
  • Kafka
  • Welcome

© 2025 · thecodestandard.com

Prev Next