DEV Community

SREY
SREY

Posted on

5 3

Operator's String And Loop's with a tint of if and else.

HELLO My dazzling friends from the internet , todays lets start by thinking what is "Operators" or why not 'String' ?
Lets see them one by one :D

Operator's

Java divides the operator in the below parts
=> Arithmetic Operators
=> Logical Operators
=> Assignment operators
=> Comparison operators
=> Bitwise Operators

Arithmetic operators consist of '+','-','*','/',and Increment and decrement ++ and -- respectively and % (modulo) .

Comparison operators consist of >,<, >= , <= , == , and !=

Logical operators consist of &&(and) ,||(or) , !(Not)

Assignment operations are = , += , -= and many more of this types .

String's In java :

Strings are used for storing text , it can be also said as the collection of words stored in double quote's

How to create a string variable
String name = "DELI" ;
Enter fullscreen mode Exit fullscreen mode

Other string method's :
length() ~ for example => name.length();
toUpperCase();
toLowerCase();

Dribble 【 ͡❛ ͜ʖ ͡❛】 :

There are many more , but all are not of use and if they are in need they can be searched on the internet .

Now lets see some concatenation

The + operator can be used between strings to combine them. This is called concatenation
for example ;

String firstName = "Elon" ; 
String SecondName  = "Musk";

System.out.print("HEY MR "+ firstName + SecondName);
Enter fullscreen mode Exit fullscreen mode

Output :
HEY MR Elon Musk

Some More Dribble :\

Ever thought of Writing code this way :

String var1 = "HEllo" ;
int var2 = "13 "
int var3 = var1 + var2    // output will be HEllo13 
Enter fullscreen mode Exit fullscreen mode

HERe we conclude Strings

Before we jump on the Loops lets start with If and else condition's

Think about what you like to eat between two things that you like the most , you might be making decisions right ....ok cool forget food for a second If today rains i will be playing and if not i will play .....or there are tons of example , similarly in coding we have set of instruction that we need to select in cases of different context so we use if else or switch

format of if else :
if (condion){
---------------
}
else{
--------------
}
Enter fullscreen mode Exit fullscreen mode
Switch
switch(expresion){
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
.
.
.
.
break ;
 default :
}
Enter fullscreen mode Exit fullscreen mode
Default keyword :

The default keyword specifies some code to run if there is no case match :)

Break Keyword :

The break keyword specifies that whenever it is seen it stops the execution in the switch and hence the statement will be printed .
A break can save a lot of execution time because it "ignores" the execution of all the rest of the code in the switch block.

Loop's

Loops are written to repeat the specific statements certain time until the condition are met .
Loops saves time , reduction of error and also can make the code DRY (do not repeat yourself)

There are three loops
=> DO while
=> While and
=> for

int i = 0;
while (i < 5) {
  System.out.println("HEY i Love to Read these JAva series ");
  i++;
}
Enter fullscreen mode Exit fullscreen mode

Output :
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series

for(int j=0 ; j<5 ; j++){
System.out.println("HEY i Love to Read these JAva series ");
}
Enter fullscreen mode Exit fullscreen mode

Output :
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series
HEY i Love to Read these JAva series

Let's conclude

THis was the basics of java it has much things that can be learned in detail if one tries to try competitive coding and learn as much as they can as said learning never stops !

Image of Bright Data

Global Data Access Unlocked – Reach data across borders without restrictions.

Unlock the power of global data collection with our advanced proxy solutions. Ideal for market research and more.

Unlock Data Now

Top comments (3)

Collapse
 
sabbat10 profile image
Sabbat Lumpatshia

Que signifie rendre le code SEC

Collapse
 
delisrey profile image
SREY

Sorry for the late reply , by the way
Can I get a clear explanation of what you are asking if possible in english cause I only understand english

Collapse
 
sabbat10 profile image
Sabbat Lumpatshia

Merci beaucoup de cette belle article

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay