Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

  • Json

    by Published on March 8th, 2011 05:07 AM
    1. Categories:
    2. General CS Concepts

    To clarify some points above I here have two classes which will look really stupid.

    Both of them are valid syntax and they show that you can use certain symbols as variable names as well as class names. It also shows you that you can create a final instance member without setting it straight away, but you HAVE to set it in the constructor or in an instance block but like above, you can only set it ONCE.

    Now for the freaky stuff.

    CAUTION: This is not best practise, DO NOT do this when programming

    public class _ {
     
        public int _ = 0;
     
        public final int __;
     
        public _() {
            this._++;
            this.__ = 5;
        }
     
        public static void main(final String... arguments) {
            final _ _ = new _();
            System.out.println("_ = " + _._);
        }
    }

    ...
    by Published on March 8th, 2011 05:05 AM
    1. Categories:
    2. General CS Concepts

    Another note to interfaces.

    When you have an interface declared like this.

    public interface Doable
    {
         int myInt = 10;
         boolean canDoIt1();
         int doIt2(int num);
    }

    The code will implicitly look like this.

    public interface Doable
    {
         [b]public static final[/b] int myInt = 10;
         [b]public[/b] boolean canDoIt1();
         [b]public[/b] int doIt2(int num);
    }
    ...