Code question (java)
At this code why don't I get true with my "fasterThan" method? public class dasd { public static void main (String args[]){ Vehicle v1 = new Vehicle(); Vehicle v2 = new Vehicle("motor",4); v1.setSpeed(3); System.out.println(v1.getName()); System.out.println(v1.getSpeed()); System.out.println(v2.getName()); System.out.println(v2.getSpeed()); v1.fasterThan(v2); } } class Vehicle{ private String name; private int speed; public String getName(){ return this.name; } public void setName(String c){ this.name = c; } public void setSpeed(int i){ this.speed = i; } public int getSpeed(){ return this.speed; } Vehicle(){ name = "car"; } Vehicle(String c, int b){ name = c; speed = b; } boolean fasterThan(Vehicle v){ if (this.speed>v.speed) return true; else return false; } }