Learn Java Tutorial for Beginners, Part 13: Classes and Objects

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024
  • New complete course: www.udemy.com/...
    More courses! Free C++ course: www.udemy.com/...
    Make a social network with Spring Boot: www.udemy.com/...
    Learn about MySQL and relational databases: www.udemy.com/...
    Java desktop programming: www.udemy.com/...
    Intermediate-Advanced C++ 11: www.udemy.com/...
    -------------------------------------------------------------------------------------------------------------------------------------------
    A basic tutorial on using classes and objects in Java, plus some discussion of what classes and objects actually are. This tutorial focuses on classes containing only data; next time I'll look at "methods".
    --------------------------------------------------------------------------------------------------------------------------------------------
    More videos on my RUclips channel: / caveofprogramming

Комментарии • 99

  • @nikiforosstaveris2484
    @nikiforosstaveris2484 7 лет назад +34

    So i play the video, listen to the music and hear that british accent-and i become certain: This guy can teach some CLASS

  • @MrKool951
    @MrKool951 9 лет назад +53

    Oh man, this ten minute video made so much more sense than my two hour lecture.

  • @thatdooddillon
    @thatdooddillon 8 лет назад +26

    I clicked on the video to learn, was greeted by some fancy piano. Top that off with a soothing British accent and some string instrumental and I felt like I had to get up and put on a suit.

  • @Ochenter
    @Ochenter 11 лет назад +1

    I have been surprised in every single tutorial you publish here. Really talented teacher you are and I like your voice and tone very much, how I wish that I'd have had a teacher ike you wether in the school or high school, as long as he would explain lessons as you do here for us.
    Thanks John !!

  • @caveofprogramming
    @caveofprogramming  12 лет назад +3

    Very funny :) I've been called worse things! Yes, standard practise is to use getters and setters to access instance data from outside the class. These I cover in subsequent videos. Have fun!

  • @caveofprogramming
    @caveofprogramming  11 лет назад +2

    You can use CSound from Java, but to be honest it's complicated and strangely rubbish. I've never heard anyone successfully make good music with it. You can write software synthesizers in Java if you want to. E.g. search for caveofprogramming blind, and you'll find some code I wrote that does basic synthesis in Java. This assumes you want an ultra-low-level approach though! Better to download Psycle if you actually want to make music.

  • @meow.4471
    @meow.4471 10 лет назад +2

    I've watched several tutorials on this subject, and this is definitely the best and most clear of all of them. Thank you.

  • @im-a-trailblazer
    @im-a-trailblazer 7 лет назад +3

    Your voice is very comforting!
    Also your explanation is very comforting.

  • @masouddayaghi5923
    @masouddayaghi5923 5 лет назад

    Thanks john for all I learnt from you, I repeat and repeat your tutorials and don't get tired watching them, they are full of details which indeed like a cave of gold you should dig it more and more.

  • @mboerrigter1
    @mboerrigter1 10 лет назад +1

    One of the better tutorials explaining classes in Java.

  • @minimalist34
    @minimalist34 8 лет назад +4

    Thank very much Cave of Programming, your tutorials are the most concise and clear explanations on important fundamental concepts, I salute you sir!

  • @karoddy44
    @karoddy44 12 лет назад +1

    You are such a wonderful teacher! I appreciate everything you are contributing and have learned a lot from you! Thank you, John!

  • @BoxedLogic
    @BoxedLogic 10 лет назад +2

    You are a hero sir,
    My teacher can't seem to explain anything I only wished I had happened upon this earlier in the semester

  • @ufucuk
    @ufucuk 11 лет назад

    I'm a long time Java Developer and I offer only your courses to my juniors at work. Great work, keep it up!

  • @benglanders
    @benglanders 6 лет назад +1

    "You can only have one public class in a file" .. no-one ever taught me this. Thankyou. :)

    • @jvsnyc
      @jvsnyc 5 лет назад

      One public "top-level" class that isn't an inner class...

  • @chrissesock4245
    @chrissesock4245 8 лет назад +6

    This was very helpful. I appreciate your reasonable pace and proper explanation.
    Absolutely subbed.

  • @razizi
    @razizi 7 лет назад +1

    Just start learning java from your excellent videos...you rock bro:) thank you

  • @xilemazeret
    @xilemazeret 11 лет назад

    i won't survive java without these videos. THANKS A LOT!

  • @adam051838
    @adam051838 10 лет назад +3

    Very nice, finally have an understanding of objects. Other tutorials aren't very clear at all, thanks! :D

  • @Anonym-mh7sz
    @Anonym-mh7sz 8 лет назад

    Some more clarification: person1 and person2 are Instances of the object Person. They basicly are their own copies of the Object. If you change variables in the Instance you wont change the variables in the object Person itself. Its more like the class Person is the blueprint fpr its instances.
    Almost everything in Java is made of Classes. if you invoke e.g. a String the string is an object somewhere in the library and you create an instance of it. This will become more clear during the next lesson "methods" because you've already worked with methods included in the String object.

  • @AutumnRide86
    @AutumnRide86 12 лет назад +1

    ahh I now associate Beethoven 4 with Java programming. You're a classy guy John. haha get 'classy'....hehe...yeah I know I need to get out more.
    One question though .At around 9:30 you say it's not good practise to do it like this, if so what is a better way? Thanks.

  • @SmartProgramming
    @SmartProgramming 6 лет назад +1

    great, really very helpful tutorial 👍👍👍👍🙂🙂🙂🙂

  • @Mahadonation1
    @Mahadonation1 9 лет назад +3

    thanks for this, the fog is starting to settle KEEP IT UP!

  • @caveofprogramming
    @caveofprogramming  12 лет назад

    Cheers! I'll try to make a video on interfaces soon. There isn't one yet, it's true.

  • @caveofprogramming
    @caveofprogramming  12 лет назад

    Thanks for the kind words. Much appreciated!

  • @estebanvprado
    @estebanvprado 9 лет назад

    You have a truly soothing voice haha and I really really like you videos. I've been trying to grasp the concept of classes and objects, and I finally feel like I'm understanding. Thanks :)

  • @decojoe5660
    @decojoe5660 8 лет назад

    your videos are the Best at breaking down Java ; Your voice sounds like Zartan from the Gi Joe cartoon. very cool

  • @mark8664
    @mark8664 6 лет назад

    Great job on your communication skills!!!!!!!!!!!!!!!!!! Now it looks like I will have a fighting chance at learning Java and Kotlin.

  • @Komplexitet
    @Komplexitet 5 лет назад

    Love the classic music. Made me feel like a sir for watching this.

  • @bobbyjones8938
    @bobbyjones8938 9 лет назад +8

    No homo, but this man accent on point and he is using all the terms like state that are 8n my book.

    • @TwinflameByond
      @TwinflameByond 9 лет назад +6

      +Bobby Jones I got a boner while listening to this. I don't even want to learn how to program, but I'm listening to his soothing voice to go to sleep.

    • @MrWhoadudewhoa
      @MrWhoadudewhoa 7 лет назад

      italian?? Dutch, dummy

    • @unlokia
      @unlokia 7 лет назад +2

      Please drop usage of this RIDICULOUS phrase _"no homo"_ - you sound INCREDIBLY insecure by saying that.
      Next, learn some sense: dailycollegian.com/2011/04/26/stop-saying-%E2%80%9Cno-homo%E2%80%9D/

  • @skdkim
    @skdkim 9 лет назад

    Wow... This video was very clear and helped me understand. Thank you!

  • @heat4life869
    @heat4life869 8 лет назад +1

    Thanks to this tutorial I have come up with this:
    >>>>>HALL OF FAME>>>>>>

  • @sukhdeogupta76
    @sukhdeogupta76 10 лет назад

    very nice video!,.could u please increase font size?..because font is not visible clearly....

  • @poiionoia
    @poiionoia 10 лет назад +1

    Finally it made sense!!! Thanks a lot.

  • @vangarecord
    @vangarecord 11 лет назад

    I think you like music.....:) and one your tutorial you told about parameter (tweaking parameter).....do
    you know which programming language is best for writing software synthesizer?

  • @mrti3
    @mrti3 10 лет назад +1

    Well explained.

  • @aqnahid8397
    @aqnahid8397 9 лет назад +3

    Really Really helpful :) Thank you so much

  • @nathanheath3756
    @nathanheath3756 9 лет назад +1

    made my lecture 1000 times easier

  • @george18almonte
    @george18almonte 6 лет назад +1

    Bro good tutorial but I think you're too close to the mic and not being loud enough which is why the air coming out of your mouth can be heard, good tutorial though like I said

  • @chedomri6060
    @chedomri6060 12 лет назад

    keep making these videos
    finally I got it!

  • @ghvy1122
    @ghvy1122 10 лет назад

    maybe a silly question, but where you declare String in your class file, 'Person', is it possible to declare String as an array, or would it not make sense to do so since you are initializing the variables in the App file?

  • @skyz3ra
    @skyz3ra 9 лет назад

    nice, nice voice also super chill, me like.

  • @glueee2621
    @glueee2621 8 лет назад +1

    Very well done video.

  • @PugzofSteel
    @PugzofSteel 10 лет назад

    Is this the same guy from udemy? It sounds just like him and the intro music is very similar to udemy's videos on the iphone app.
    Very good video I'll have to watch it again though.

  • @ratnakumari9059
    @ratnakumari9059 10 лет назад

    Thank u john...well explained..

  • @alexmen95kn
    @alexmen95kn 10 лет назад

    Excellent!

  • @alialkhatab
    @alialkhatab 9 лет назад

    The program cant find the main class, I have this problem when I write before public

  • @Soulfyres
    @Soulfyres 8 лет назад

    Voice is very ASMR haha. This tutorial still applies but for new people I would recommend checking out Java 8 tutorials for the most up to date usage of Java. Don't learn old material

    • @Locationary
      @Locationary 8 лет назад

      +King Kek any tips on where his only got one video on java 8

    • @Soulfyres
      @Soulfyres 8 лет назад

      Locationary Personally I bought a course for 10 bucks from udemy, full video course. There are plenty of java 8 ebooks out there you can torrent (before buying ;)) and if you are into gaming it can also be useful to look up runescape java 8 bot making tutorials as it is funner for a gamer and put's things into context for you.

    • @Locationary
      @Locationary 8 лет назад

      King Kek hahaha that's pretty funny you mention that since I use to program scripts for a runescape bot called kbot 7 or so years ago but I forgot most of the coding which is why I'm learning again

  • @Claymore2408
    @Claymore2408 11 лет назад

    Thanks for these videos.

  • @RaymondLee1220
    @RaymondLee1220 9 лет назад

    Thanks!

  • @thexxmaster
    @thexxmaster 9 лет назад

    Thanks for this.
    I don't understand why you need to declare what 'type' the person1 variable is?
    I'm referring to the 'Person person1 = new Person()' line.
    I would understand if it was like this ' person1 = new Person()' as you are creating a new object but i don't understand why there is the need for the first person.
    Any help would be great.
    Cheers

    • @johnpurcell827
      @johnpurcell827 9 лет назад

      +thexxmaster Some languages let you miss off the type or write "auto" or "var" or something, but Java doesn't. The type of the variable doesn't have to be Person here; it could be any superclass of Person (like Object), or any interface that Person implements, depending on how you need it to work.
      You can create variables without using "new" to make them point at an actual object. But since you often want to combine variable declaration with initialising the variable, many other languages let you miss off the type of the variable in this situation. Maybe Java will in the future.

    • @thexxmaster
      @thexxmaster 9 лет назад

      Oh okay that makes more sense. Thanks a lot I appreciate it.

  • @Copexify
    @Copexify 6 лет назад +1

    5:37 GENERAL KENOBI!!!!

  • @mark8664
    @mark8664 6 лет назад

    Whoever invented Java involuted it.

  • @dunbustin
    @dunbustin 8 лет назад

    If you declare a variable of type Person by putting Person person1; you get the message that it has not been initialised when you attempt to assign age and name values to it.

    • @johnpurcell827
      @johnpurcell827 8 лет назад +1

      You need Person person1 = new Person().
      The "new" is what actually creates the object containing your data and code. The bit of the left of the equals sign only declares a variable that can refer to an object.

    • @dunbustin
      @dunbustin 8 лет назад

      It did work if I put, Person person1; person1 = new Person();

  • @Abliskarian
    @Abliskarian 6 лет назад

    I thought you can only have one public class in a file but then u just went ahead and created class person right above public class App????

  • @Thegamer-yp7qq
    @Thegamer-yp7qq 9 лет назад

    can I write .. string name ; and int age;
    outside any class . and would make the same effect ????

    • @johnpurcell827
      @johnpurcell827 9 лет назад +1

      +The gamer Yes, but you'll see if you continue to study programming that being able to group data together with subroutines helps massively to organise code and keep it understandable. So it's much more useful than it first looks.

  • @shilpagupta844
    @shilpagupta844 7 лет назад

    hello Sir,
    Here you have not declared the class PERSON as Public...so how it is getting accessed in main ??
    is that ..the class person is bydefault public ?

    • @zani0090
      @zani0090 7 лет назад

      yes. if you dont put a access modifier as public or private your class will be public

  • @_slier
    @_slier 10 лет назад

    what is the purpose of `public` keyword infront of a `class` ?

    • @_slier
      @_slier 10 лет назад

      ah ic..thank you sir

  • @mithunmanoharmithun
    @mithunmanoharmithun 10 лет назад

    Great!!

  • @lachlanperrier2851
    @lachlanperrier2851 10 лет назад

    my god thank you aout this for spelling it out for me

  • @w33dnesday
    @w33dnesday 8 лет назад +1

    creating person/ people actually is called having sex so programmers arent that nerd how they seem

  • @VoNoWaR
    @VoNoWaR 8 лет назад +1

    video leaked: programming class from the renaissance

  • @dafdarf
    @dafdarf 10 лет назад

    Ignore this if it's explained later, but so far ...
    I'm baffled that you created a new class called "Person" and defined variables (name & age) in it, but the objects of that class (person1, etc) are not actually IN that class, but in the main class. most peculiar, momma

    • @dafdarf
      @dafdarf 10 лет назад

      ***** Thanks, the light is slowly coming on. Sounds like the objects defined by a class actually "live" within a method - where they are used. If so ... your method tutorial is next up for me, so hopefully it'll become clear then.
      Thanks again. If all this goes according to plan, I hope to find work and I will owe you a percentage of my earnings.

  • @skullie6024
    @skullie6024 4 года назад

    Got it

  • @tarcal87
    @tarcal87 6 лет назад

    1.25x speed is a must

  • @MikeBlackford
    @MikeBlackford 10 лет назад

    no no... i make others brains bubble out their ears :-P lol i like the video.

  • @dumdum3067
    @dumdum3067 9 лет назад +2

    super annoying, the wet sound in his mouth is louder then him talking..

    • @Dustinh911
      @Dustinh911 8 лет назад

      He needs to remove the mic from his esophagus

  • @barshabhattacharjee6788
    @barshabhattacharjee6788 4 года назад

    For more visit: ruclips.net/video/wbrWpt--cgw/видео.html

  • @noahmassey42
    @noahmassey42 6 лет назад

    Have you heard of a glass of water?

  • @MBG-ck9ou
    @MBG-ck9ou 7 лет назад

    I can hear this guy's saliva building up in his mouth goddamn

  • @MrAbbasalrassam
    @MrAbbasalrassam 6 лет назад

    Really Badddddd >???????

  • @abrahamamsel6780
    @abrahamamsel6780 6 лет назад

    Thank you!