• 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

What Is A Computer Program?

Dec 21, 2018

A computer program is a useful piece of code written[...]

Interfaces

Jan 25, 2019

Understanding Interfaces Interfaces are abstract classes. We don’t usually put the abstract keyword at[...]

What Is A Computer?

Dec 21, 2018

First we will start off with the dictionary definition of[...]

Recent Posts

  • Producer
  • Interfaces
  • Abstraction
  • Polymorphism
  • Conditional Statements

Categories

  • Basics
  • Kafka
  • Welcome

© 2025 · thecodestandard.com

Prev Next