Results 1 to 2 of 2
Thread: Static class
- 12-31-2007, 10:21 AM #1
Member
- Join Date
- Dec 2007
- Posts
- 49
- Rep Power
- 0
- 12-31-2007, 01:02 PM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
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.
Java 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: Learn Java by Examples
Similar Threads
-
Abstract Class with Static Methods
By bugger in forum New To JavaReplies: 7Last Post: 09-05-2008, 12:20 AM -
Explicit static initialization with the static clause
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:07 PM -
Mocking static methods of class
By Kat in forum New To JavaReplies: 3Last Post: 11-08-2007, 12:24 AM -
Error: Non-static method append(char) cannot be referenced from a static context
By paul in forum Advanced JavaReplies: 1Last Post: 08-07-2007, 05:05 AM -
Error: non-static variable height cannot be referenced from a static context at line
By fernando in forum AWT / SwingReplies: 1Last Post: 08-01-2007, 09:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks