xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to create class constructor with parameters in Java
Java Online Editor
Execute Code
More Java Sample Codes
public class ExampleApp { public static void main(String[] args) { // Parameter values are passed at the time of class instantiation (object declaration) Person personObj = new Person("John", 25); System.out.println(personObj.getName() + " is " + personObj.getAge() + " years old."); } } // This is a class class Person { // Class fields private String name; private int age; // This is a class constructor public Person(String name, int age) { this.name = name; this.age = age; } // Getter method for name property public String getName() { return name; } // Getter method for age property public int getAge() { return age; } }