Zero to FAANG (Day Seven)--Typecasting, Automatic promoting expression,if condition,while loop and for loop
Namaste everyone🙏|| Today i learnt typecasting,while loops and for loops. Now i can say that Java syntax is so hard to get it. I tried so many times to know about syntax but i couldn't able to get it. Have every sucks at syntax is programming language. Shame on me.
This line is so much hard to get.
Scanner. Input= new scanner(system.in);
I knew that scanner is class. And input is a object of this class. But, why this =new scanner(system. In). What does it mean?
Still I am not getting it. So moved further which was primitive datatypes
The simple messaging is primitive datatypes is those datatypes whoms literal cannot change their datatypes after if they will get broken.
For an example--if I break string value into chunks. Let's say sahil into s,a,h,i,l. It is not considerable as string now it is a character.
But if I cut integer values it will be same datatypes value.
Actually there are some things which called typecasting. If I ask for integer value to user and he type float valve then compiler will give error. So if it wouldn't have to happen. We use typecasting thing.
Int num=(int) (57.78f);
Automatic casting. It is also a great featured which can be helpful. The amazing thing I learnt. The Java language is unicode. It means any language can uses into program. Like Hindi Marathi Panjabi ketti etc
There are rules which Java follows while doing automatic promoting expression.
1. Short, long, byte will promote into int.
2. If we are doing any operation, in that operation if there is long the m then whole operation will consider as long
Kunal taught if conditions ,while loops and for loops.i don't need to mention how I learn this things because I already knew through c++ language.but he told how to guess that when we should use while loop and for loops. The simple answer is when you know how many times loop should be run you can use for loop. When you don't know you can use while loop 😅.
So. I learnt alot. Thanks Kunal