top of page

RECENT POSTS: 

FOLLOW ME:

  • Facebook Social Icon
  • Twitter Social Icon

Class Structure and Object Creation

  • Sree Hari
  • Mar 8, 2017
  • 1 min read

Previous Blog: JVM - JRE - JDK

Book.java

public class Book {

            private String name;

            public Book (String name) {

                        this.name = name;

            }

            public void whoAmI () {

                        System.out.println("I am " + name);

            }

            public static void main(String[] args) {

                        Book book1 = new Book("Java, The Complete Reference");

                        Book book2 = new Book("Heads First Java");

                        book1.whoAmI();

                        book2.whoAmI();

            }

}

Output

I am Java, The Complete Reference

I am Heads First Java

All the world’s a stage,

And all the men and women merely players;

They have their exits and their entrances,

And one man in his time plays many parts

                                             - William Shakespeare

........

Comments


© 2023 by Closet Confidential. Proudly created with Wix.com

  • b-facebook
bottom of page