Classy Engineers
3 min readMar 15, 2021

--

I am excited to be here with all of you, Let’s start Learning!! In this section, we deal with some basics of Java along with illustrated coding examples. To know more about how to install Java and what you can do with Java go to our previous blog, You will discover great utilization of java there. Here we will learn about variables and conditional statements.

As a Recap, Java is a Portable, Robust, and secure object-oriented high-level programming language. Do you know about the most important feature of Java? It is platform-independency i.e When you save your code and after that when you compile it then java converts your compiled code into bytecode and this byte code can run on any JVM regardless of the fundamental PC design. That’s why Java is said to be a write-once, run anywhere(WORA) language.

Okay, now I will not intimidate you by saying code!code!code! It’s time to show you basic java coding stuff. So, lets deep dive into variables and conditional statements :

Let’s get started with Java!

Variables: A variable is a piece of memory for storing data values. A variable can contain any type of value based on different data types in java. Data Types like int, byte, string, float, boolean, and many more. Let us take a simple example to understand the variable:

In the above code, one is the integer variable that contains integer value 1 and bool_value is a boolean variable that contains the value true.

  • Conditional Statements: Conditional Statement helps you to make a decision, based on a certain condition. As in real life, how do we make decisions? Like tomorrow morning if there will be rain outside then I will not go to school otherwise I will go. Also to take a specified action in java we use conditional statements like ”if”, ”nested-if”, ”if-else”, ”if-else-if “, “Switch-case“. Let us see these statements in coding:

-The if statement advises our program to execute a specific segment of code just if a specific test assesses to true.

Code in the if block executes only as the condition is true. So, It will print “I am in if block”.

  • The nested-if statement is an if-else statement with another if statement. First, it checks if the outer-if condition is true then only enters into the inner-if and then executes code according to the evaluation of the inner-if condition.

To know more click on: https://classyengineers.com/why-variable-and-conditional-statements-is-so-prominent/

--

--

Classy Engineers

Classy Engineers is a blog, where you can find concepts related to Lifestyle and Technology. 😊 Website link: https://classyengineers.com/