Search:

Type: Posts; User: Cornix

Search: Search took 0.20 seconds.

  1. Replies
    16
    Views
    1,520

    [SOLVED] Re: Compile error for enhanded for loop

    You can not define attributes within a constructor, or any method for that matter.
    Attributes of a class can only be defined outside of methods.

    With the second approach you are not supposed to...
  2. Replies
    16
    Views
    1,520

    [SOLVED] Re: Compile error for enhanded for loop

    Thats not quite how the singleton pattern works.
    Here, take a look at this example, maybe it can help you:

    Our singleton

    public class Config {

    public static final Config INSTANCE = new...
  3. Replies
    16
    Views
    1,520

    [SOLVED] Re: Compile error for enhanded for loop

    What your "controller" classes are depends on your application.
    There exists a certain programming paradigm which is called Model-View-Control (MVC). The idea is, that your classes are loosely...
  4. Replies
    16
    Views
    1,520

    [SOLVED] Re: Compile error for enhanded for loop

    This way you still keep the variable totalAttributes. It will forever stay in your memory as a package-private static variable of your Globals class.

    By the way, a class like this is heavily...
  5. Replies
    16
    Views
    1,520

    [SOLVED] Re: Compile error for enhanded for loop

    Just so you know, the variable TOTAL_ATTRIBUTE_VALUES is NOT a constant at this point.
    Its value can still be changed at any point in time.

    If you want it to be a constant you need to do a little...
  6. Replies
    16
    Views
    1,520

    [SOLVED] Re: Compile error for enhanded for loop

    Several problems here:

    int totalAttributes;
    for( int value : attributesFinal ) {
    totalAttributes =+ value;
    }
    public static int TOTAL_ATTRIBUTE_VALUES = totalAttributes;
    First of all,...
Results 1 to 6 of 6