He is talking about complete range not range complete range is -128 to 127 which is 128+127 = 255 but we also have to include 0 in between -128 to 127 so it becomes 256 as complete range. Hope that helps
May when u reverse an int..which starts with low digit num and ends with 8or 9 ..when u reverse it will exceed the limit.so u use type cast and many more eg
As you mentioned a =b is implicit conversion , does it mean the data type of b has now become int or its simply a temporary conversion while assigning value to a.
when ever we perform any mathematical operation on number the result is promoted to integer even in case if add 1 and 2. EX byte a=1; byte b=2; byte c = a+b; will give error we have to change the c variable type to int or we need to type cast the result to int.
We are not increasing the capacity of the datatype. A byte will still store max value of 127. For eg. int a = 45; byte b = a; (wrong) This doesnt work because we are assigning an int value to the byte. This is where casting is helpful. Correct solution: byte b = (byte) a; However, if the value of a was say 250, and we assigned it to byte b using casting: byte b = (byte) a; this will not give an error, but it wil start the counting again after 127 since 127 is the max value allowed in byte. so, after 127 we go back to -127 and start the counting again. if you calculate this for 250, you will get the answer as -6. Hope that helps!
@@CodingBirdsOnline that's total of positive and negative range lets take(-128=128 and 0 to 127=128 include "0" both 128 together makes 256) actually that's not a good practice. But, I had done this in my compiler then used this technique it worked well and sticked with it. (x is your value do x - 256).
one of my buddy suggested your channel. so far i have done one month of my programming fundamental course in university ( in Canada ). super frustrated at the moment ..not understanding anything...fyi i have never done anything at all regarding this ...should i quit or do something else or just follow blindly ? i dont wanna just by heard everything ...i actually wanna learn these stuff ...but i just cant get a hold of it .
You shouldn't just give up on it, you can try learning python first as it is way easier then move on to Java or c++, the python knowledge will really help you
The code below prints 0. Why? TIA. public class Test { public static void main (String [] args){ int a =256; byte b; b= (byte) a; System.out.println(b); } }
Int x =10; here 'int' is a data type, 'x' is a name of the variable, '=' (equal) is a operator , '10' is a "constant value or literal" and ';' (semicolon) is a separator. Hope you understand what a literal is in java.
Need help, please explain difference in the following code: double d=5.67d; long a=(long)d;// Difference bwetween This code long b=(long)Math.floor(d);//and this code
Hi I’m not too sure if you still needed help. But seems code #1 is simply converting the variable d into a long and stored into A Second code is converting the variable d into a long and stored into B. However since it is a floor function it means it will always round it down I believe. Example the floor of 5.9 is 5 while the floor of 5.1 is 5.
Hi Naveen, when i try to run this i do not get the remainder instead java prints 259 on my screen class typecast { public static void main(String args[]) { int i = 259; byte by = (byte) i; System.out.println(i); } } TERMINAL OUTPUT : PS C:\Users\HP\OneDrive\Desktop\java> java typecast.java 391 PS C:\Users\HP\OneDrive\Desktop\java> PLEASE HELP ME WITH THIS
He is talking about complete range not range complete range is -128 to 127 which is 128+127 = 255 but we also have to include 0 in between -128 to 127 so it becomes 256 as complete range. Hope that helps
No one on youtube can match this guys level in Java
you really teach good, the concepts, which we need as a engineer just not syntax of any programming language
U & code with Harry are amazing teachers 😅😅
should we use byte in for loop instead of int? e.g. for(byte i=0; i
Your teaching skill is amazing..😊
Great explanation👍
T+e+l+u+s+k+o = 7 = Thala for reason
😂😂😂
😂😂😂
🤡
Yevaru bro nuvvu mari intha talented ga vunnav
😂
Awesome, the concepts explained are concise and to the point
Love you from uzbekistan 💯
Sir does this playlist cover all core java concepts..because your explanation was awesome.....
6:02 range of byte is 127 sir why 256 is divided plz. Clarify
He is talking about complete range not range complete range is -128 to 127 which is 128+127 = 255 but we also have to include 0 in between -128 to 127 so it becomes 256 as complete range. Hope that helps
Total range in 256, so -128 to +127 total count is 256 including 0
Give definitions about every topic it will be helpful to people to crack the interview pls try if possible?
Great explanation ,Very much helpful
Such a nice explanation ❤️
0:30
can uh also tell us where to practice more of the topic manually , which makes us confident in java
Let's keep aside
And just a normal question
Why is typecasting needed??
May when u reverse an int..which starts with low digit num and ends with 8or 9 ..when u reverse it will exceed the limit.so u use type cast and many more eg
Hi sir do you provide online classes personally?
As you mentioned a =b is implicit conversion , does it mean the data type of b has now become int or its simply a temporary conversion while assigning value to a.
when ever we perform any mathematical operation on number the result is promoted to integer even in case if add 1 and 2. EX byte a=1; byte b=2; byte c = a+b; will give error we have to change the c variable type to int or we need to type cast the result to int.
Brooo
But why that happens
because of type promotion@@learnwithmecoders
just by saying a keyword casting there can we increase the capacity of the datatype to store a larger value?
We are not increasing the capacity of the datatype. A byte will still store max value of 127.
For eg.
int a = 45;
byte b = a; (wrong)
This doesnt work because we are assigning an int value to the byte. This is where casting is helpful.
Correct solution:
byte b = (byte) a;
However, if the value of a was say 250, and we assigned it to byte b using casting:
byte b = (byte) a;
this will not give an error, but it wil start the counting again after 127 since 127 is the max value allowed in byte.
so, after 127 we go back to -127 and start the counting again.
if you calculate this for 250, you will get the answer as -6.
Hope that helps!
@@anshulgoyal597 amazing explanation💯😃
I have a question: when I assign byte value to 128, it will print -128 . what is the reason for that?
coz the range of byte is of -128 to 127 (inclusive) ,so when u say 128 it comes back to the frst min value,-128
128-256=-128
@@satyacharan9019 what is 256 here?
@@CodingBirdsOnline that's total of positive and negative range lets take(-128=128 and 0 to 127=128 include "0" both 128 together makes 256) actually that's not a good practice. But, I had done this in my compiler then used this technique it worked well and sticked with it.
(x is your value do x - 256).
@@satyacharan9019 can this logic be applied to int, float or double when doing type casting?
❤ from Andhra Pradesh
You are amazing thank you so much!
one of my buddy suggested your channel. so far i have done one month of my programming fundamental course in university ( in Canada ). super frustrated at the moment ..not understanding anything...fyi i have never done anything at all regarding this ...should i quit or do something else or just follow blindly ? i dont wanna just by heard everything ...i actually wanna learn these stuff ...but i just cant get a hold of it .
You shouldn't just give up on it, you can try learning python first as it is way easier then move on to Java or c++, the python knowledge will really help you
The code below prints 0. Why? TIA.
public class Test {
public static void main (String [] args){
int a =256;
byte b;
b= (byte) a;
System.out.println(b);
}
}
256 % 256 = 0
You didn't specify the value of b and said it would be it % 256 so it took 256 % 256, which is 0.
public static void main(String args[ ]) why did he change a to args?
Literals some of them were not understanding how many literals are there what represent what i don't no plz explain
Int x =10;
here 'int' is a data type, 'x' is a name of the variable, '=' (equal) is a operator , '10' is a "constant value or literal" and ';' (semicolon) is a separator. Hope you understand what a literal is in java.
Not those
Values
@@esha9493 hi
8th grade Brightlanders be suffering.😅
(Brightlanders=students of Brightlands School)
(Brightlands= a very famous school in Dehradun (
Byte range is till 127 ,but how we are dividing 256 with 257, please anybody can answer
I too
Had same doubt
Actually its -128 to 127 so total value is 256 that's why we're dividing it from 256
I know I'm too late maybe you've got your answer yet
Need help, please explain difference in the following code:
double d=5.67d;
long a=(long)d;// Difference bwetween This code
long b=(long)Math.floor(d);//and this code
Hi I’m not too sure if you still needed help.
But seems code #1 is simply converting the variable d into a long and stored into A
Second code is converting the variable d into a long and stored into B. However since it is a floor function it means it will always round it down I believe. Example the floor of 5.9 is 5 while the floor of 5.1 is 5.
Thank u so much sir
Hi Naveen,
when i try to run this i do not get the remainder instead java prints 259 on my screen
class typecast
{
public static void main(String args[])
{
int i = 259;
byte by = (byte) i;
System.out.println(i);
}
}
TERMINAL OUTPUT :
PS C:\Users\HP\OneDrive\Desktop\java> java typecast.java
391
PS C:\Users\HP\OneDrive\Desktop\java>
PLEASE HELP ME WITH THIS
HI it would be amazing if someone can help me out
You are printing the value of 'i' variable
I did the same mistake :P
Thankyou sir
why it use 256 to perform module operation
My right ear 😢
Good evening india
Good Night
0:18
3:40
even in the range of byte aslo the byte is not working for result..........
I use Code Runner Extension
Sir, please take 1 question and slove that question in Java
9:55 but range of the byte is 127 then how did he divide 257%256
And he said range of the byte is 256 how ?
🤔
He is talking about complete range not range complete range is -128 to 127 which is 128+127 = 255 but we also have to include 0 in between -128 to 127 so it becomes 256 as complete range. Hope that helps
i was confused too, i read someone's answer explained it
@@West-zee can u explain it .
I'm still confused 😕
September 2024 😂
The dude has his phone number in the description, although he basically has 2m subs💀
Nov 2024
sorry sir
Hj
average vid mid it is