same name defined for method and object?
public class MyClass { public static void main(String[] args) { Car Car1 = new Car(); // to be removed System.out.println(Car1.Brand); } } class Car1 { static String Brand = āToyotaā; } // class to be removed class Car() { String Brand = āAudiā; } === Now I have learnt a few types of entity (or āthingā? I donāt know how to call themā¦), namely object, class, method and variable/attribute. If I give the same type of āthingā the same name, it looks like Eclipse will warn me about this (like, when I created two classes named āCarā, an error message will be shown. I did not test other types of āthingsā though). I then suspected what would happen if I name different types of things the same name. In the above example, I name a class Car1 (attaching a static label āToyotaā), but at the same time, name an object Car1 (attaching a label āAudiā) as well, which was created from another class Car(). When I print the label, āAudiā poped up and it looks like āToyotaā was overidden. To make sure I did not write the syntax wrong, I deleted the parts indicated above and re-ran the program, and āToyotaā poped up. So my questions are: 1. Why does the object takes over the class when calling the expression āCar1.Brandā? In what order does java consider in this situation? 2. Why wasnāt any warning shown for this?