Java Programming - Lecture 4

preview_player
Показать описание
This lecture finishes the object concept and starts to explain the concept of inheritance. A simple inheritance example is given.
Рекомендации по теме
Комментарии
Автор

Awesome lectures with supporting materials, much appreciated, Thanks Very Much

ShivJalli
Автор

I think there is a simple way to implement compare method
public int compare(Temperarute t1, Temperature t2){
float value1=t1.getTempC();
float value2=t2.getTempC();
if(value1==value2) return 0;
else if(value1>value2)return 1;
else return -1;
}

mlabouardy
Автор

1:19:00 Downcasting is certainly allowed in java, although many consider it to not be a best practice, when the base (parent) class has value of a derived (child) class: 
Parent par = new Child(); // UPCAST
Child ch = (Child) par;   // DOWNCAST

RicochetRita
Автор

Hi Barbara have quite a few doubts about synchronized keyword in java. Could you please clear this doubt by explaining an eample???

lazybuddies
Автор

I'm confused, if she hasn't taught if statements and operators, how does she expect the class to know how to finish the assignment?

corydavis
Автор

Wouldn't the name variable inside the Dino class be n rather than dname to match the name variable in Tetra?

christophermock
Автор

i dont see the nececitty for static methods in this assignment. Why not just use  (non-static)methods through the objects we create?
for instance: my convert method looks like this: 

void compareT (Temperature a, Temperature b){
             if(a.scale == b.scale){
                     System.out.println("same scales");
                     if (a.degrees > b.degrees){
                             System.out.println("a is higher");
                       } else System.out.println("a is lower");
                }

             if(a.scale != b.scale ){
                    System.out.println("different scales");
                    convertT(b);
                    if (a.degrees > b.degrees){
                         System.out.println("a is higher");
                     } else System.out.println("a is lower");
               }
    }

There i have my 2 temperature objects passed as parameters.

when i use this method in my main, it doesnt matter through which instance i used the method:
one.compareT(one, two);
two.compareT(one, two);
three.compareT(one. two);
its all the same.. one and two being compared.

DerMagnar
Автор

Hello.

    If we are using the basic wrapper model (bean) you should override int compareTo(Object obj), boolean equals(Object obj), String toString().

jamespsims
join shbcf.ru