I watched some of your C++ videos (until I found out I was in the wrong class) and this is the first time using this for java. You do a great job making it simple for beginners. Thanks a ton...you have been a great help for me.
You are super duper awesome. You really made me to understand and how to build from the basic. Each and every videos are filled with golden keys. Thank You
Thank you for this. Only halfway through the video, and already drawn more knowledge from it than the hour(s) I spent trying to learn objects on docs. Great explanation of why you use getters & setters, encapsulation and whatnot. Thank you, this is gold
The whole reason to generate those getters and setters was to make your instance variables private, and you didn't do just that. private int id; private String name; private int age; is the way to go. (In your Student class.)
I don't know if you still on YT, but could you elaborate on your suggestion? Should I instead of Getting and Setting just put the private infront of the datatypes or how would it work, bc if I just "add" private infront of id and String it tells me that Student.name etc. is not visible....
@@britninja5969 No he is saying the point of adding the getters and setters is so your variables can be private. So make your variables private AND use the getters and setters. This way, the variable can only be accessed the way you intend them to be.
@@maXImuS9683 Author of article probably didn't want to confuse non - hard core programmers. He wanted to avoid confusing people by bringing in more concepts such as private at this stage.Umer is obviously a more knowledgeable or even probably a hard core programmer.
getters and setters are preferred because this way you can keep the *variables* private (makes application more secure), and set or get the values by using public methods.
Very clear explanations. You've clarified my doubts about objects and classes in java, and in particuler the use of getters and setters to encapsulate data. Thank you, Sir. May God bless you in this endeavor!
Awesome explanation Bro...I have seen many videos on getter and setters but i never understand how it works. But this video was lifesaver. Thank you so much bro.
6:54 syso control + shift It is not working for me, how is it done? Edit: I found out that I can type syso and press Control + Shift + Space at the same time.
@@silasdietrich7464 Oh, I forgot about this comment. However, I already found the solution it was syso then Control + Shift + Space. Thank you for your help I will consider editing the comment.
Can you please do a similar tutorial where we can use arrays and taking inputs of the students int, name and age and to also be able to assign a desired number of students? This would be awesome. Keep up the great work. You make things easy to understand. So much easier than my teacher at university.
i use jgrasp... when i try to call the getter method in the main i get errors "saying value not found" for the .getName and .getAge methods even though they are in my Student class. Any help?
In the class declaration, you need to add "private" before variable declaration so they cannot be accessed. The way you showed in the video they are still accessible by unwanted users.
So Basically we create a separate class and we declare some attributes there. Then we call this sub class into the main one, assign to it an object and then call the attributes of the subclass to each object?
Sir, U have shown the use of getter and setter methods. My query is can we get input from user for id, name and age using scanner object in one class and call the methods in second class which has main method. Thanks in advance.
This has been tremendously helpful, thank you so much! If I were to do this using notepad since my college class requires us to not use a compiler, when I create separate classes, are they separate notepad files that I just put in the same folder? Thanks so much!
Hi, thank you for this wonderful video. I was so confused trying to understand classes using textbooks and this was gold. Just a quick question: Shouldn't tom.setId(2)? In your video, tom.setId(1) which I'm guessing will override Mark's id?
Hi..Its a set of very useful lectures...I would like to know how data corruption is avoided here with getters and setters because here also we are trying to hard code inside set method in myclass.java?..forgive me if this is juvenile as i am trying to learn java
Sivagama Sundari . He meant that data type of the instance variable cannot be changed. You can make the instance variables PRIVATE from PUBLIC and you can use getter,setter methods to access them.
I agree with +Michael Saneke can you create a tutorial for creating an address book GUI with a table you can sort by field and add, delete, sort, search, etc? Without using Eclipse only a text editor?
hi all while writing code after giving dot after mark in the pop up box id name are not coming .can anyone help me to resolve this issue. I am new to java.Thanks
I am facing a problem....... When i am trying to import any variable from a class it show me a error like id is a variable so it is showing "id cannot be resolved or is not a field."......... Hep me Thanks
hiya, When i try to setName,id,age with scanner. Id and Age works but for name ; it didnt want me to type a name ! and say " "; " is 2 years old"; thank u
'this' is a java keyword which stores reference to the current class. So in the example above 'this' really means 'Student' class. In other words, by saying: this.id = id; we're meaning to say Student.id = id;.(cant use this notation though as it will be illegal). why illegal.. that's probably beyond the scope of this tutorial but keep following.. you'll get it.
prathamesh sawant this is the reference to the o jet of class which called this method not the class there might be multiple java objects but only one calling this perticular method so this keyword is used to get the reference of perticular object
Similar code package first; public class MyProgram{ public static void main(String[] Args) { info Rohan = new info(); Rohan.name="Rohan"; Rohan.bday=11; Rohan.bdaymnth="september"; Rohan.bdayr=2003; System.out.println(Rohan.name+" was born on "+Rohan.bday+" "+Rohan.bdaymnth+","+Rohan.bdayr+"."); System.out.println("similarly"); info Ritesh = new info(); Ritesh.name = "Ritesh "; Ritesh.bday = 14; Ritesh.bdaymnth = "August"; Ritesh.bdayr = 1994; System.out.println(Ritesh.name+"was born on "+Ritesh.bday+" "+Ritesh.bdaymnth+","+Ritesh.bdayr); } }
As long as it's still Java. However, making setters and getters is probably slightly different. Different menus to click the button that is, but should still work the same.
Before you understand code you will hate it, once you understand it, you will enjoy speaking it.
I am stuck with class in Java. I know that basic but this getin function is complicated
Steve, honestly
FUCK YOURSELF
Spot on Steve
Ya u r true! Coding is so addictive once you understand it
Faith Biete man ty for this quote ,it’s hard for me to put effort into this java class but this will definitely help🙌🏾
Make sure you change the batteries on your smoke detectors.
I am curious to know what this quote really mean? Sorry if it might be a silly question.
I am curious to know what this quote really mean? Sorry if it might be a silly question.
@@vananhle-bacquelot4832 ok no problem
Actually I think he smokes while shooting video
just learnt something i never understood all through out my programming life in the university .thank you
I watched some of your C++ videos (until I found out I was in the wrong class) and this is the first time using this for java. You do a great job making it simple for beginners. Thanks a ton...you have been a great help for me.
i clicked on an Ad , hope that could benefit you in some way ;)
Thanks for the tutorial.
Good job :D
very good :)
You are super duper awesome. You really made me to understand and how to build from the basic. Each and every videos are filled with golden keys. Thank You
Thank you for this. Only halfway through the video, and already drawn more knowledge from it than the hour(s) I spent trying to learn objects on docs. Great explanation of why you use getters & setters, encapsulation and whatnot. Thank you, this is gold
The whole reason to generate those getters and setters was to make your instance variables private, and you didn't do just that.
private int id; private String name; private int age; is the way to go. (In your Student class.)
constructive criticism. important information. thanks.
I don't know if you still on YT, but could you elaborate on your suggestion? Should I instead of Getting and Setting just put the private infront of the datatypes or how would it work, bc if I just "add" private infront of id and String it tells me that Student.name etc. is not visible....
@@britninja5969 No he is saying the point of adding the getters and setters is so your variables can be private. So make your variables private AND use the getters and setters. This way, the variable can only be accessed the way you intend them to be.
@@maXImuS9683 Author of article probably didn't want to confuse non - hard core programmers. He wanted to avoid confusing people by bringing in more concepts such as private at this stage.Umer is obviously a more knowledgeable or even probably a hard core programmer.
I love you man you make this so easy to understand
After all these years, I finally understood why do we need to use the keyword this. Thank you very much!
Really helpful and clear, you make everything very simple
Thanks aloooot
getters and setters are preferred because this way you can keep the *variables* private (makes application more secure), and set or get the values by using public methods.
Sagar Mishra you can just make get as public not the set because anyone can set the value of your variables
Very clear explanations. You've clarified my doubts about objects and classes in java, and in particuler the use of getters and setters to encapsulate data. Thank you, Sir. May God bless you in this endeavor!
its very simple to understand from your tutorials sir, specially practical work, great 👍👍
Awesome explanation Bro...I have seen many videos on getter and setters but i never understand how it works. But this video was lifesaver. Thank you so much bro.
This is such a helpful tutorial on classes and objects! Love it! No better feeling than helping people learn :)
Hey I am a beginner in programming ...should I follow this course or should I need to learn c or cplus plus ...please guide me bro
6:54
syso control + shift
It is not working for me, how is it done?
Edit: I found out that I can type syso and press Control + Shift + Space at the same time.
Control + Space is the shortcut :)
@@DJABA Yeah it seemed to be changed via new updates releases thanks mate
@@alexschmidt4371 try typing the letters 'sout' and then enter (should be the first option)
@@silasdietrich7464 Oh, I forgot about this comment. However, I already found the solution it was syso then Control + Shift + Space. Thank you for your help I will consider editing the comment.
how does getter and setters protect from data corruption please explain? a programmer can change id, age,name in both the cases u have shown
Yes I really want to know this
abhishek mahtta he forgot to mention the access specifiers for instance variables + set methods to private and get and set as public
abhishek mahtta these ide development tools make things easier to layout code but fir in depth study best guide is documentation
THANks bros for supporting
you are a great tutor , cleared my confusions by showing the difference between the two codes and explained it very well!! thank you
Good tutorials.
Use 1.5x speed if he's going to slow for you.
Very nice work and kudos for teaching us the core topics in easy way. way to go!
thank you so much! I will pass my test tomorrow thanks to you :))
i am also a beginner and i am study from eclipses as i am following him
Excellent, brief, and clear. Good Job! I'll be searching for more of your videos.
Keep on going dude! these really helped.
thx man! it really helps me to understand class and object in java. keep it up the good work!
Can you please do a similar tutorial where we can use arrays and taking inputs of the students int, name and age and to also be able to assign a desired number of students? This would be awesome. Keep up the great work. You make things easy to understand. So much easier than my teacher at university.
Buenas noches, el video fue muy sencillo y bien explicado, gracias por aportar tu conocimiento y experiencia. Desde Venezuela.
Thanks I understand it just a little bit better now.
Thanks for the video i understood this by yr video otherwise i was badly confused...
my teacher doesnt teach so im here for help! THANK YOU!!
thank u very much..it was very helpful and so easy to understand..
if it wasn't for these videos, ide be struggling in my computer science class. Thank you for the awesome content
You are really awesome man
This was very helpful!Thank you!!
Really good tutorial go to 2x speed if he's going too slow because that's what I use and it's just brilliant
dude put a new battery in smoke detector
Hatts off bro.....Appreciate ur work ...Thanx alot for it
Sir I am getting error by - student canot be resolved to a type, please help me.
Great explanation. Thank you.
Good explanation my friend. I did a 2X speed guys, if he is teaching for beginners
I think you are teacher from God☝👏
Thank you very much, super helpful video
TX, nice & easy to follow, when are you doing the advanced part of Java i.e. Networking, Database and etc.
i use jgrasp... when i try to call the getter method in the main i get errors "saying value not found" for the .getName and .getAge methods even though they are in my Student class. Any help?
In the class declaration, you need to add "private" before variable declaration so they cannot be accessed. The way you showed in the video they are still accessible by unwanted users.
You need constructors if you use a private class. He'll cover it later I guess?
So Basically we create a separate class and we declare some attributes there. Then we call this sub class into the main one, assign to it an object and then call the attributes of the subclass to each object?
Very easy to understand tqq u so much sir
thanks for the explanation!
Sir, U have shown the use of getter and setter methods. My query is can we get input from user for id, name and age using scanner object in one class and call the methods in second class which has main method. Thanks in advance.
Good Java learning tutorial.
This has been tremendously helpful, thank you so much! If I were to do this using notepad since my college class requires us to not use a compiler, when I create separate classes, are they separate notepad files that I just put in the same folder? Thanks so much!
Can we create Object outside the main method ?
thanks, but which of these classes is testclass here??
Hi, thank you for this wonderful video. I was so confused trying to understand classes using textbooks and this was gold. Just a quick question: Shouldn't tom.setId(2)? In your video, tom.setId(1) which I'm guessing will override Mark's id?
+rjvnz yes it should be tom.setId(2)
It won't override though, theyll just have same ID
Hi..Its a set of very useful lectures...I would like to know how data corruption is avoided here with getters and setters because here also we are trying to hard code inside set method in myclass.java?..forgive me if this is juvenile as i am trying to learn java
Sivagama Sundari . He meant that data type of the instance variable cannot be changed. You can make the instance variables PRIVATE from PUBLIC and you can use getter,setter methods to access them.
sir,if we havent use getters and setters in the student class..they cant be used in my class?
Is Getters and setters can be done with normal command prompt
Why not make the field variables private?
I agree with +Michael Saneke can you create a tutorial for creating an address book GUI with a table you can sort by field and add, delete, sort, search, etc? Without using Eclipse only a text editor?
sir but can we do this all thing in the single class
GREAT VIDEOS! THANKS!
In Netbeans 8 i am getting an error with my strings "Colour is erroneous" for example. Can someone help
Can someone explain why is it important to go the getters and setters way rather than accessing the values directly?
some people dont like indian accent. but here enjoying the video
mark is not the object or instance it is refrence variable which carries the refrence id of the object ::)
wonderful video but this detectors are really annoying
Yh wala program agr written mh likhy ...toh kasy likhy gy...bcz yh alg classes hai 2
hi all while writing code after giving dot after mark in the pop up box id name are not coming .can anyone help me to resolve this issue. I am new to java.Thanks
I am facing a problem....... When i am trying to import any variable from a class it show me a error like id is a variable so it is showing "id cannot be resolved or is not a field."......... Hep me Thanks
hiya, When i try to setName,id,age with scanner. Id and Age works but for name ; it didnt want me to type a name ! and say " ";
" is 2 years old";
thank u
is it similar to structures in c?
You could have used private variables after using getters and setters
I'm beginner, but i still don't comprehend how he explain the "Method Overloading" tutorial.
sugoi desu
Sugoi sugoi
@@muntazirm1794 wakarimashta
I still dont understand why we need encapsulation and how somebody can corrupt the data if int id;String name;int age still existing in the class?
Thank you for the assistance
what is meant by " new " ??? can anyone explain ???
its an operator for creating new objects
Can someone explain which part is missed with protecting your data. Which ones should have been private?
why did he have it on public?
what is the use of new????
how i can create class inside main class using notepad .......
what is that "this.id=id:" used for?
Do you know now?? xD
'this' is a java keyword which stores reference to the current class. So in the example above 'this' really means 'Student' class. In other words, by saying: this.id = id; we're meaning to say Student.id = id;.(cant use this notation though as it will be illegal). why illegal.. that's probably beyond the scope of this tutorial but keep following.. you'll get it.
lol I think he forgot to use it in the output
prathamesh sawant this is the reference to the o jet of class which called this method not the class there might be multiple java objects but only one calling this perticular method so this keyword is used to get the reference of perticular object
sir please provide tutorial for struts and hibernate
get rid of that piping sound, please :P
Needs to change batteries on his smoke detector lol
why do we use the word "NEW" and what is use of that
thank you ... really helpful :)
Can we use Scanner class ???
An error is thrown when I've used scanner class
Easy!!! Thanks.
Please Sir,
Suggest me correct code for this program .I faced execution error in this code
package Calculation;
import java.util.Scanner;
public class Calculator {
static char choice;
static int a1, b2 , ad, sb, ml, dv,pr;
public static void main(String[] args) {
System.out.println("Enter first number");
Scanner num1 = new Scanner(System.in);
a1 = num1.nextInt();
System.out.println("Enter sevond number");
Scanner num2 = new Scanner(System.in);
b2 = num2.nextInt();
System.out.println("Enter + for addition");
System.out.println("Enter - for subtraction");
System.out.println("Enter * for multiply");
System.out.println("Enter ÷ for division");
System.out.println("Enter # for clear screen");
System.out.println("Enter % for percentage");
System.out.println("Enter calculation choice");
Scanner scan = new Scanner(System.in);
choice = scan.next().charAt(0);
switch(choice){
case '+': addition ad1 = new addition();
ad = ad1.Add(a1 , b2 );
System.out.println("addition is" +ad);
break;
case '-':subtraction sb2 = new subtraction();
sb = sb2.Sub(a1 , b2);
System.out.println("Subtraction is"+sb);
break;
case '*': multiplication mul3 = new multiplication();
ml = mul3.Mul(a1, b2);
System.out.println("Multiplition is" +ml);
break;
case '÷': division dv4 = new division();
dv = dv4.Div(a1,b2);
System.out.println("Division is" +dv);
break;
case '%': percentage pr5 = new percentage();
pr= pr5.Per(a1, b2);
System.out.println("percentage is" +pr);
break;
}
}
}
dont we have to have Private instances on other class then its worth to setters and getters there.
ITS NOT GETTING AN output ..its saying student cannot be resolved into a type
Thank you!
Similar code
package first;
public class MyProgram{
public static void main(String[] Args) {
info Rohan = new info();
Rohan.name="Rohan";
Rohan.bday=11;
Rohan.bdaymnth="september";
Rohan.bdayr=2003;
System.out.println(Rohan.name+" was born on "+Rohan.bday+" "+Rohan.bdaymnth+","+Rohan.bdayr+".");
System.out.println("similarly");
info Ritesh = new info();
Ritesh.name = "Ritesh ";
Ritesh.bday = 14;
Ritesh.bdaymnth = "August";
Ritesh.bdayr = 1994;
System.out.println(Ritesh.name+"was born on "+Ritesh.bday+" "+Ritesh.bdaymnth+","+Ritesh.bdayr);
}
}
is this code work in netbean as well?
As long as it's still Java.
However, making setters and getters is probably slightly different.
Different menus to click the button that is, but should still work the same.
you have told that using getter and setter u can secure your data ,but u don't have told how it is doing that. Please focus on logics also
Bhai 5 fps pe q record kiya?
Is it inheritance ?
Whos here before the CMSC 131 final?
Thanks a lot
Listen to this in 0.25 speed...... It's so funny🤣🤣
Saptangshu Manna so true! 😂😂