Answer to Question #248248 in Java | JSP | JSF for Tege

Question #248248

Explain constructor with examples


1
Expert's answer
2021-10-07T16:40:32-0400
/*
 * Example two
 * In this case Constructor with parameters will build Circle object with definite radius
 * */
public class Circle {
	int radius;


	public Circle() {


	}


	public Circle(int radius) {
		this.radius = radius;
	}


	public void setRadius(int radius) {
		this.radius = radius;
	}


	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS