Skip to content

natanleal1/JavaExercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 

Repository files navigation

Take your coffe and let's enjoy Java!

Here some exercises during my Practice learning Java and Oriented Object Programming

  • Learned how to manage Objects;
  • Learned how to manage Setters, Getters and Constructors;
  • Learned how to set up a package in this Programming Language;
  • Inheritance and Polimorphism;
  • Conclusion: It isn't as difficult as people say if you learned other Programming languages;

Some Knowledge:

  • All classes or at least one class is son of Object -> For example in my NaloFlix exercise the Object Titulo doesn't extend anything even 'cause that is the Mother of all classes, even though it extends Object behind the scenes.

  • Why when printing a object it shows the object@somenumbers ? This happens because sout converts the object into a String and the String gets the object and uses this code:
getClass().getName() + '@' + Integer.toHexString(hashCode())

  • You cannot inherit the constructor

  • You can have two variables that work as a reference to one object
Movie movie = new Movie();
Movie lordOfTheRings = movie;
// references but the same object, this is just a form of expressing the same thing
  • Sometimes you will face the misterious problem of CompareTo -> In my NaloFlix exercise when having to order a List I had problems because the Collection.sort() could not order Object because it uses the compareTo() behind the scenes so I went in my SuperClass Titulo and made a @override and made when comparing the objects, get name from them and comparing these Strings.
@Override
    public int compareTo(Titulo anotherTitle) {
        return this.getName().compareTo(anotherTitle.getName());
    }

About

Learning the coffe language and its processes!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages