Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java Constructors
class Rextester { // Rextester = Car int wheelsCount; int numbersOfSeats; int windows; public Rextester(){ wheelsCount = 4; numbersOfSeats = 4; } public Rextester(int number){ numbersOfSeats = number; } //Constructor Overloading public Rextester(int a, int b){ wheelsCount = a; numbersOfSeats = b; } //Copy Construction public Rextester(Rextester c){ wheelsCount = c.wheelsCount; numbersOfSeats = c.numbersOfSeats; } public void start(){ System.out.println("Car is starting"); } public static void main(String[] args) { Rextester c1 = new Rextester(1,7); c1.windows = 6; System.out.println(c1.wheelsCount); System.out.println(c1.numbersOfSeats); System.out.println(c1.windows); Rextester c2 = new Rextester(c1); System.out.println(c1.wheelsCount); System.out.println(c1.numbersOfSeats); /* Car c1 = new Car(); c1.wheelsCount = 4; c1.numbersOfSeats = 4; c1.windows = 6; System.out.println(c1.wheelsCount); System.out.println(c1.numbersOfSeats); System.out.println(c1.windows); System.out.println("************************"); Car c2 = new Car(); c2.wheelsCount = 4; c2.numbersOfSeats = 4; c2.windows = 8; System.out.println(c1.wheelsCount); System.out.println(c1.numbersOfSeats); System.out.println(c2.windows); */ } }
run
|
edit
|
history
|
help
0
First Unique Character in a String
ElaineBrown**
sfr
linked lists
Leetcode 297. Serialize and Deserialize Binary Tree
Problem: on_off
Area of the triangle
problem 11: java program 11
Fibonacci numbers 0 - 94
Street light