How to Implement Multiple Attributes in Java


In this example we will show you how to implement multiple attributes in Java.

Source Code

package com.beginner.examples;


public class Person {
  String name = "Luckey"; // String
  int age = 16; // int

  public static void main(String[] args) {
    Person p = new Person();
    System.out.println("Name: " + p.name);
    System.out.println("Age: " + p.age);
  }
}

Output:

Name: Lucky
Age: 16
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments