• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the difference between these three variables in the class declaration area?  RSS feed

 
Justin Robbins
Ranch Hand
Posts: 121
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between these three variables of a class:

public MyClass {
private String s = "Hello";
private String s1;
private Static String s3 = "Dog";
}

Why does the option exist to create it in those ways? What are the benefits?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The first two are instance variable declarations. The third is a static variable declaration.

As for what they do, do you know the different between an instance and a static variable?

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!