Thread: Static class
View Single Post
  #2 (permalink)  
Old 12-31-2007, 03:02 PM
wsaryada wsaryada is offline
Senior Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 102
wsaryada is on a distinguished road
A class cannot be static, but for you purposes you can set the attributes and methods to be static. This way you can access it without create an instance.

Code:
public class Constant { public static final String ERROR = "1"; public static String calculate(int number, int number) { // } } public class Test { public static void main(String... args) { String error = Constant.ERROR; Constant.calculate(1, 10); } }
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Reply With Quote