Variable initialization

Hello guys,
Is there anybody know how and when java checks for variable initialization?For example if we change a value, assume a without initializing it we get variable a might not have been initialized.I wish to know how java checks that the variable is already assigned or not.
int a;
a++;//How java checks this
regards,
Haddock

Rules is:
To variables of instance - It's default value attribute automatically if not initialize with value.
To local variable (methods for example) - It's default value in initialization has been MUST attributed
Instance variables has a folliwing default value:
class A{
int i; //default value is 0
char c; //default value is '\u0000'
byte b; //default value is 0
short s; //default value is 0
long l; //default value is 0
float f; //default value is 0.0
double d; //default value is 0.0
boolean bl; //default value is false
String str; //Object is always null
int x[]; // null. It's Object's array
int x[5]; // 5 times default value 0.
void testInitializeValue(){
int x; // Compiler error; This variable has been initialized
if(x == 5){
return;
Ok..Thanks!!

Similar Messages

  • Message variable initialization

    Hello,
    We had this ridiculous situation a while ago where out service instances create their variables with multiple nodes.
    For example if we have xsd looking like this:
    <element name="Response">
    <complexType>
    <sequence>
    <element name="Result">
    <simpleType>
    <restriction base="string">
    <enumeration value="OK"/>
    <enumeration value="ERR"/>
    </restriction>
    </simpleType>
    </element>
    <element name="Comment" minOccurs="0" type="string"/>
    </sequence>
    </complexType>
    </element>
    In BPEL we have message variable which part is this "Response" element. Everything is fine till the moment we start getting initial variable looking like this:
    <outputVariable>
    <part name="payload" >
    <Response>
    <Result/>
    <Result/>
    <Result/>
    <Result/>
    <Result/>
    <Result/>
    </Response>
    </part>
    </outputVariable>
    Of course we have no reason for this, no logs, no info and so on. Any idea anyone?
    Everything is normal concerning the BPEL, no errors are raised till the moment we need to populate the variable. The process is working correctly but we cannot return result to the caller.
    WL version: 10.3.5.0
    SOA version: 11.1.1.5.0
    BPEL version: 2.0
    Best regards.

    could you please send your test case to our support team? this doesn't look right. bpel engine would initialize the variable based on the xpath usage in to-spec expressions. you can try turning of variable initialization for that particular component using bpel.config.initializeVariables to false. and go with literal xml variable initiation. [http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.html#SA00038]
    http://docs.oracle.com/cd/E28271_01/dev.1111/e10224/bp_manipdoc.htm#BABHDFBJ
    here is the sample for that property
    in composite.xml, find the component, under that component add this property, and re-deploy with your literal variable init.
    <property name="bpel.config.initializeVariables">false</property>

  • Class variable initialization

    I have noticed that class variable initialization occurs AFTER the constructor is called.
    Why is this, and is this intentional?
    It has caused strange behaviour in my SE java applications I am porting to MIDP.
    Thanks
    - Adam

    Hi,
    Error 1:
    The problem only arises if you use the unassigned variable:
    int i;
    int y = i; // Use of unassigned variable here
    you can just assign a value to i to solve this:
    int i = 0;
    int y = i; // Use of unassigned variable here
    Error 2 and 3 have to do with static and non-static, not with the initialization per se. This is how it works:
    static members (e.g. fields) can be accessed using this syntax: <Classname>.<FieldName>, e.g:
    public static class Helpers
    public static int SomeDataValue { get; set; }
    class Program
    static void Main(string[] args)
    Helpers.SomeDataValue = 22;
    On the other hand, non-static members are accessed like this: <instance>.<fieldname>. So you always need an instance of a class to access the field:
    public class Order
    public int OrderNumber { get; set; }
    class Program
    static void Main(string[] args)
    Order o = new Order();
    o.OrderNumber = 12;
    Rgds MM

  • Variable initialization error

    import java.io.*;
    import java.util.*;
    import java.sql.*;
    public class ReadCSVFile
    public void StatementQuery(String Version , String Doctype_id)
    String docfamilyid,docfamilyid_upd;
    String sqlstr = "select DOCFAMILYID_ID from master table where doctypeid=\""+Doctype_id+"\"";
    public static void main(String[] args)
    ReadCSVFile obj = new ReadCSVFile();
    String str,doctype=null,version=null,doctype_id=null;
         int i=0;
         String prevdoctype,prevdoctype_id;
    try
    BufferedReader in = new BufferedReader(new FileReader("RecordsNet_DocType_List1.csv"));
    while ((str = in.readLine()) != null)
    String s[] = str.split(",");//splitting string based on ','
    if (s[1]!=null)
         doctype_id=s[1];
              if (s[5]!=null)
    doctype=s[5].trim();
    if (s[8]!=null)
    version=s[8];
    if (s[1].length()==0 && s[5].length()==0)
         System.out.println("Another version for "+ prevdoctype_id);
    if ( doctype.equalsIgnoreCase("Statement")) {
              obj.StatementQuery(version,doctype_id);
              prevdoctype_id=doctype_id;
         if ( doctype.equalsIgnoreCase("Report Class A")) {
                        //System.out.println("Report Class A"+ i + doctype);
                        prevdoctype_id=doctype_id;
         if ( doctype.equalsIgnoreCase("Report Class B")) {
                        //System.out.println("Report Class B"+ i + doctype);
                        prevdoctype_id=doctype_id;
         if ( doctype.equalsIgnoreCase("Report Class D")) {
                                  //System.out.println(doctype);
                                  prevdoctype_id=doctype_id;
         if ( doctype.equalsIgnoreCase("Trade Confirm")) {
                                  //System.out.println("Trade Confirm"+ i + doctype);
                   prevdoctype_id=doctype_id;
    in.close();
    catch (IOException e)
    }//class main end
    }// class ReadCSVFile end
    error is
    variable prevdoctype_id might not have been initialized
    if i initialize it then it get's initialized everytime..but when some parameters are blank in a file i just want to resuse the value stored in variable prevdoctype_id

    if i initialize it then it get's initialized everytime.You only need to initialize it one time outside of the while loop for example by setting it to null then the variable is initialized and it will not be overwritte each time.
    btw. the
    if (s[X]!=null)seems to be wrong.
    a) array indices are 0 based. i.e. the first index is 0
    b) split returns an array of Strings based on the regular expression
    so will split return a one element array for the String "token 1" containing ["token 1"]
    a three element array for the String "token 1, token 2, token 3", containing ["token 1", "token 2", "token 3"]
    You should replace your
    if (s[X]!=null) {
    }by
    if (s.length > X) {
    }

  • Row-Wise Session Variable Initialization Block (Max Rows)

    Hi, we have a problem with Row-Wise Session Variable.
    We'll try to implemented the security with a External Query and a Row-Wise Initialization Block. But when we'll try to open the Web Obiee and the rows of result of the query is more than 3000 rows, the browser is broken. The access is very slowly.
    When the result of Query to Row-Wise Variable is more than 3000 rows and we'll try to open the Web Obiee, we have to close NQServer.EXE process of Obiee Server.
    Is there a best practise or a limit rows in the Row-Wise Initialization Block?.
    Thanks.

    You're Right, the people can't be in 3000 groups.
    Is possible I don't explain my problem correctly.
    We use this Row-Wise Variable for implement Data Level Security. .
    For Example :
    I have a fact table with Offices and Office's Sales.
    And each Obiee User can see many Offices according to their level of security.
    I want filter the fact table using a external SQL table implemented in a Session Row-Wise Variable and a User can have X Offices (In the worst case, 3000 Offices).

  • Inheritance - instance variable initialization

    Hi all.
    I have a question regarding inherited instance variables.
    class Animal {
       int weight;
       int age = 10;
    class Dog extends Animal {
       String name;
    class Test {
       public static void main(String[] args) {
          new Dog();
    }This is just an arbitrary code example.
    When new Dog() is invoked, I understand that it's instance variable "name" is give the default
    type value of null before Dog's default constructor's call to super() is invoked.But Im a little perplexed about
    Animals instance variables. I assume that like Dog, Animals instance variables are given their default type values
    of 0 & 0 respectively, before Animals invocation of super(); What im unclear about is that at the point that weight and age are given their default type values, are Dog's inherited weight and age variables set to 0 aswell at that exact moment? Or are Dog's inherited weight and age variables only assigned their values after Animals constructor fully completes because initialization values are only assigned to a classes instance variables after it's call to super().
    Many thanks & best regards.

    Boeing-737 wrote:
    calvino_ind wrote:
    Boeing-737 wrote:
    newark wrote:
    why not throw in some print statements and find out?Super() or this() have to be the very first statement in a constructor..
    Also you cannot access any instance variables until after super or this.
    :-S
    Kind regardsbut if you add the "print" statement in animal constructor, you can easily see what happened to the attributes of Dog ; that s the trick to print "before" super()You can never add a print before super(). It's a rule of thumb, super() and this() must always be the first statements
    in a constructor, whether added implicitly by the compiler or not. In this case there are 2 default constructors (inserted by the compiler), each with a super() invocation. Even if i added them myself and tried to print before super(), the compiler would complain.
    Thanks for the help & regards.you didn't understand what i meant ; take a look at that:
    class Animal {
       int weight;
       int age = 10;
       public Animal() {
           Dog thisAsADog = (Dog) this;
          System.out.println(thisAsADog.name);
          System.out.println(thisAsADog.x);
    class Dog extends Animal {
       String name;
       int x = 10;
    public class Test {
       public static void main(String[] args) {
          new Dog();
    }this way you will know what really does happen

  • [OT] surprising instance variable initialization exception behavior

    No real question here. Just something that caught me quite off guard. I thought I understood the object instantiation process pretty well, but there's clearly at least one significant gap in my knowledge.
    Not surprisingly, the following gives "Error:Error:line (4)unreported exception java.lang.Exception; must be caught or declared to be thrown" for the new WTF2() line.
    public class WTF1 {
      private final WTF2 wtf2 = new WTF2();
      WTF1() /* throws Exception */ {}
    class WTF2 {
      WTF2() throws Exception {}
    }Quite surprisingly (to me at least) if we uncomment "throws Exception" in the WTF1() c'tor declaration, the compiler is happy.
    Reading [JLS 12.5 Creation of New Class Instances|http://java.sun.com/docs/books/jls/third_edition/html/execution.html#12.5], I can see that executing the instance initializers is step 4 of "the indicated constructor is processed to initialize the new object using the following procedure", so I guess I can see how executing the initializer can be considered "part of" executing the c'tor, and hence covered by its catch block. It just looks a little weird, and I always thought that the initializer executed before the c'tor, and had to catch checked exceptions.
    Now that I've learned something, I'm ready to count this day as a win and head to the pub. :-)

    BIJ001 wrote:
    wtf2 is an instance variable, so (the appropriate copy) must be initialized in (every) constructor.Eh? No.
    It's final, so therefore it must have it's value set by every normal completion of every ctor. But that's irrelevant to what I'm looking at. I'm talking about the fact that the declaration/initialization line complains or doesn't based on the throws clause of the c'tor.
    I see now why it works that way, but I just thought the initializer execution was "outside of" the c'tor execution. I thought that if new WTF2() could throw a checked exception, I'd have to do something like we do for static initializers:
    private final WTF2 wtf2;
      try {
        wtf2 = new WTF2();
      catch (Exception e) {
        throw some unchecked exception
    }As it turns out, the initializer is executed "inside" the c'tor in a way I didn't expect.

  • Multiple variable initialization using arrays

    Hi,
    In my program I want to initialize some 20 odd variables(all of the same type) to the same value having their names as Input1, Input 2 .. Input 20. Want I want to do is to use an array to do this rather than writing the 20 variables one after the other. Is there any way to do so ?
    Please help.
    Thanx in advance,
    Gaurav

    Hi Again,
    I am sorry for framing the question wrongly. What i want exactly is this :
    I want to create a variable no. of arrays (the number of arrays will be inputed by the user). I want to initialize them ,something like this
    int Input1 [] = new int [400];
    int Input2 [] = new int [400];
    After this initialization I will then fill these with some info. from a file and then use it in my program.
    So I want to use a for loop or some other loop so that I can achieve this.
    Please help,
    Thanks
    Gaurav

  • PartnerLink Input Variable initialization error for xsd:any datatype

    I have a web service which use the xsd:any for the message type( segment of the wsdl given below):
    - <message name="post_ps_apg_services0Request">
    <part name="fa_form" type="**xsd:any**" />
    </message>
    <portType name="ps_services_wsPortType">
    - <operation name="post_ps_apg_services">
    <input name="post_ps_apg_services0Request" message="tns:post_ps_apg_services0Request" />
    <output name="post_ps_apg_services0Response" message="tns:post_ps_apg_services0Response" />
    </operation>
    <binding name="ps_services_wsBinding" type="tns:ps_services_wsPortType">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
    - <operation name="post_ps_apg_services">
    <soap:operation soapAction="" style="rpc" />
    - <input name="post_ps_apg_services0Request">
    <soap:body use="literal" namespace="ps_services_ws" />
    </input>
    - <output name="post_ps_apg_services0Response">
    <soap:body use="literal" namespace="ps_services_ws" />
    </output>
    </operation>
    <service name="ps_services_ws">
    - <port name="ps_services_wsPort" binding="tns:ps_services_wsBinding">
    <soap:address location="http://spider.apollogrp.edu:4400/sst/runtime.asvc/ps_services" />
    </port>
    </service>
    I have created a Partnerlink Invoke_ps_apg_services with Input Variable 'Invoke_ps_apg_services_post_ps_apg_services_InputVariable'.
    During Compilation of the process I get the following exception:
    Error: Couldn't initialize variable.
    Error occurred while initializing BPEL variable "Invoke_ps_apg_services_post_ps_apg_services_InputVariable" at line 51, the schema processor could not find type "{http://www.w3.org/2001/XMLSchema}any" for part "fa_form", in the following schemas:
    Schema 0 ---> namespace=http://edu.apollogrp.ws.ps_services/Ips_services_ws.xsd
    location=file:/C:/BPELProjects/FAPP/FAPP_PS_Service/bpel/PostFAFormsPSSchema.xsd.__OAUX_GENXSD_.TOP.XSD
    Schema 1 ---> namespace=http://xmlns.oracle.com/pcbpel/adapter/jms/
    location=file:/C:/BPELProjects/FAPP/FAPP_PS_Service/bpel/jmsAdapterInboundHeader.wsdl.__OAUX_GENXSD_.TOP.XSD
    Schema 2 ---> namespace=null
    location=file:/C:/BPELProjects/FAPP/FAPP_PS_Service/bpel/FAPPService.wsdl.__OAUX_GENXSD_.TOP.XSD
    Please make sure that the type "{http://www.w3.org/2001/XMLSchema}any" is valid in your wsdl.
    Has anyone have seen this error ? What is the fix/workaround ?
    Thanks in advance

    The "any" type is not defined in the standard http://www.w3.org/2001/XMLSchema namespace. Try changing the type name to "anyType" and it should not give that error anymore.
    The valid types defined under that namespace are located at [http://www.w3.org/TR/xmlschema-2/#built-in-datatypes|http://www.w3.org/TR/xmlschema-2/#built-in-datatypes].

  • Shared Variable Initializa​tion

    For whatever reason if I use shared network variables over the network they take 20 seconds each to initialize... after all of them initialize they are very fast.  Does anyone know why it would take exactly 20 seconds for this to occur?  If i look at the variables in variable manager i can see the update values and they are exactly 20 seconds apart.  This occurs weather i'm using a library with 20 variables or one with only 1 variable. 

    Hi Tak321,
    You can change the gateway address in the network properties on Windows (if that is the operating system you are using), however, doing so could disrupt your communications to your building network.  It does sound like it is possible that the shared variables are routing through the other network.  You could try disabling that network adapter to be sure.  It is also possible to bind shared variables to a specific network card: http://digital.ni.com/public.nsf/allkb/D358BABAE2F​61F1A862571570056867D?OpenDocument
    Regards,
    Jeremy_B
    Applications Engineer
    National Instruments

  • Problem with Session variable initialization block

    Hi,
    I'm getting strange results when using session variables in my repository files.
    I have created session variables as specified in the document which is available at
    http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/bi_admin/biadmin.html
    The main problem getting with the system session variable (USER) in the select statement.
    My select statement is as follows,
    select ':USER',case when upper(':USER') = 'KUMAR' then 'APR-05' end from Dual
    The problem is while logging into the BI Answers it is allowing all the invalid users to login who does not exist.
    when i remove the quotes and simply use :USER in the select statement it is not allowing the invalid users to login but giving error while displaying the results.
    when i remove the user variable from select statement its giving correct results.
    Can i know what is causing the problem.
    Thanks,
    Kumar.

    Hi DK,
    Check out my post Rowlevel Security?? and see if it helps you.
    Cheers!
    -Joe

  • Local variable initialization

    How local variables initialized in CVI?
    Are there any default values for local variables?

    Following function is generated by IVI Scope driver generator.
    If the vertical coupling is GND, variable simOffset is used in an equation without being initialised.
    Is this a bug and it must be initialized?
    * Function: TTTTT_FetchWaveformSafe
    * Purpose: This function returns the data from the instrument. You must
    * range-check all parameters and lock the session before calling
    * this function.
    static ViStatus TTTTT_FetchWaveformSafe (ViSession vi, ViConstString channelName,
    ViInt32 waveformSize, ViReal64 waveform[],
    ViInt32 *actualPoints, ViReal64 *initialX,
    ViReal64 *xIncrement)
    ViStatus error = VI_SUCCESS;
    if (!Ivi_Simulating (vi)) /* call only when locked */
    ViSession io = Ivi_IOSession (vi); /* call only when locked */
    ViChar rdBuf[5000];
    checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));
    /*=CHANGE: ==============================================================*
    Do actual instrument I/O only if not simulating. Example:
    viCheckErr( viPrintf (io, ":WAV %sATA?", channelName));
    viCheckErr( viRead (io, rdBuf, 5000, VI_NULL));
    Change the number of elements in the rdBuf array as appropriate for your
    instrument's maximum record size.
    Convert the rdBuf raw data here to a double precision floating point
    numbers and store the data in the waveform array.
    Read the waveform preamble from the instrument to get the initial X
    and X increment values.
    If the oscilloscope did not resolve all points in the waveform record,
    replace such points with the IVI_VAL_NAN value. The function should
    return the TTTTT__WARN_INVALID_WFM_ELEMENT
    warning in this case.
    *============================================================END=CHANGE=*/
    else
    ViInt32 x;
    ViReal64 yRange, simOffset;
    ViInt32 triggerSlope, vCoup;
    ViReal64 k, level, theta, offset;
    checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL,
    TTTTT_ATTR_HORZ_RECORD_LENGTH,
    0, actualPoints));
    checkErr( Ivi_GetAttributeViReal64 (vi, channelName,
    TTTTT_ATTR_VERTICAL_RANGE,
    0, &yRange));
    checkErr( Ivi_GetAttributeViInt32 (vi, channelName,
    TTTTT_ATTR_VERTICAL_COUPLING,
    0, &vCoup));
    checkErr( Ivi_GetAttributeViReal64 (vi, channelName,
    TTTTT_ATTR_VERTICAL_OFFSET,
    0, &offset));
    checkErr( Ivi_GetAttributeViInt32 (vi, VI_NULL,
    TTTTT_ATTR_TRIGGER_SLOPE,
    0, &triggerSlope));
    checkErr( Ivi_GetAttributeViReal64 (vi, VI_NULL,
    TTTTT_ATTR_TRIGGER_LEVEL,
    0, &level));
    checkErr( Ivi_GetAttributeViReal64 (vi, VI_NULL,
    TTTTT_ATTR_HORZ_TIME_PER_RECORD,
    0, xIncrement));
    checkErr( Ivi_GetAttributeViReal64 (vi, VI_NULL,
    TTTTT_ATTR_ACQUISITION_START_TIME,
    0, initialX));
    theta = asin (2*level/yRange);
    if (triggerSlope == TTTTT_VAL_POSITIVE)
    k = 1.0;
    else
    k = -1.0;
    if( *actualPoints>waveformSize )
    *actualPoints = waveformSize; /* Checking number of points to write */
    *xIncrement /= *actualPoints;
    if (vCoup == TTTTT_VAL_DC)
    simOffset = 0.5;
    if (vCoup == TTTTT_VAL_GND)
    k = 0.0;
    for (x = 0; x < *actualPoints; x++)
    ViReal64 y = simOffset + k * 2.5 * sin (*xIncrement * 12560 * x + k * theta) + // ~2 periods of 1kHz sinewave
    (!(x%20)) * (16384 - rand())/150000.0;
    waveform[x] = (offset + yRange/2) > y ? ((offset - yRange/2) < y ? y : (offset - yRange/2)) : (offset + yRange/2);
    Error:
    return error;

  • About variable initialization

    Hi,
    I would like to know the difference between the following two initializations :
    Initializing the object inside the constructor and outside the constructor..
    class Test {
    FooObj obj ;
    public Test() {
    obj = new FooObj();
    and
    class Test {
    FooObj obj = new FooObj();
    public Test() {
    Can you pl. let me know..
    Thanks
    Devi..

    class One {
        private ArrayList data;
        public One()
            data = new ArrayList();
    class Two {
        private ArrayList data = new ArrayList();
        public Two()
    bytecodes:
    class playground.One extends java.lang.Object {
        public playground.One();
    Method playground.One()
       0 aload_0
       1 invokespecial #1 <Method java.lang.Object()>
       4 aload_0
       5 new #2 <Class java.util.ArrayList>
       8 dup
       9 invokespecial #3 <Method java.util.ArrayList()>
      12 putfield #4 <Field java.util.ArrayList data>
      15 return
    class playground.Two extends java.lang.Object {
        public playground.Two();
    Method playground.Two()
       0 aload_0
       1 invokespecial #1 <Method java.lang.Object()>
       4 aload_0
       5 new #2 <Class java.util.ArrayList>
       8 dup
       9 invokespecial #3 <Method java.util.ArrayList()>
      12 putfield #4 <Field java.util.ArrayList data>
      15 returnSo it looks equivalent to me. I prefer to initialize outside of the constructor unless arguments are needed to create the instance.

  • About static variable initialization

    Here is an exercise where you have to guess the output :-)
    public class MyClass{
        private static int x = getValue();
        private static int y = 5;
        private static int getValue(){
            System.out.print("Running getValue ");
            return y;
        public static void main(String[] args){
            System.out.println(x);
    }This code outputs "Running getValue 0" I don't understand why?

    because class initialisation will call getValue() before it initialises 7 to 5, thus setting x to the value y has before being initialised which is 0.
    What this tells you is that you should never program rubbish like that, and in general not rely on the value of uninitialised members.

  • Enforce setting private variable in subclass with abstract method

    Hi,
    Is this something that is common usage/practice?:
    public abstract class Base {
        private int importantPrivateVariable = setImportantPrivateVariable();
        protected abstract int setImportantPrivateVariable();
    }I would like to enforce the extender of the class to set a private variable, but as there is no abstract variable in java, I can only use a method for it.
    Thanks,
    lemonboston
    Edit: the variable could be protected as well, I suppose this is not important here, but correct me if I am wrong

    lemonboston wrote:
    Hi,
    Is this something that is common usage/practice?:I don't think that's so common, but that's code easily understandable. However there are several problems with this approach:
    public abstract class Base {
    private int importantPrivateVariable = setImportantPrivateVariable();
    protected abstract int setImportantPrivateVariable();
    }I would like to enforce the extender of the class to set a private variableThat's no what your code implements: your base class forces the subclasses to return an int value, and the Base class uses that value to assign it to the variable.
    Therefore the method should be called get<Something> (e.g. <TT>getInitialValueOfImportantVariable()</TT>+ to have a naming consistent with its signature (it returns a value, whereas a regular setter method should declare a void return type: <TT>protected abstract void setImportantPrivateVariable(int someValue);</TT>).
    Edit: the variable could be protected as well, I suppose this is not important here,Well, yes, this is "important" - at least, there a noticeable difference: the variable being private, the base class is free to handle it as it sees fit (e.g., assign the value at construction time and never modify it afterwards). If the variable was protected, the subclass could modify in ways and at times not known by the base class.
    but correct me if I am wrongThere's a trap in this construct: the method is called in the variable initializer, that is, behind the scenes, approximately during the execution of the Base class constructor, so before the subclass constructor. So, you are calling a method on an object that is not fully initialized (e.g. some of its attributes may still be <TT>null</TT> at this stage). There is a rule that discourages such situations, that goes something like "don't call non-private and non-final methods from a constructor".
    To avoid this trap, two options:
    - require an int argument in the Base class's constructor , as was suggested above
    - don't get and set the value of the important variable in the initializer or constructor code, but from a special method in the base class instead:
    public abstract class Base {
        private int importantPrivateVariable; // default value is zero
    // or alternatively:
    //    private int importantPrivateVariable = ...; // Some default value
        protected abstract int getImportantPrivateVariable();
        public void initializeImportantPrivateVariable() {
            importantPrivateVariable = getImportantPrivateVariable();
    }That construct is a degenerate form of a common design pattern known under the name of Template Method (where a base class method calls generally several subclass methods in a specified order and with a specified chaining, leaving it to the subclass to implement the details of the methods).
    The drawback is that the client code (the one that uses the Base instance) has to know when to call that initialization method, whereas the constructor-based initialization lets the client code free to not care at all.
    Much luck,
    J.

Maybe you are looking for

  • Udevd synclient messages while booting

    Hi all, I get messages like these while starting udevd ("Starting UDev Daemon" and "Waiting for UDev uevents to be processed") on my laptop: udevd[241]: ´usr/bin/synclient TouchPadOff=1´ [627] exit with status 0xffffffff udevd[241]: ´usr/bin/synclien

  • Using 3gs cable for charging 4s is good ?

    hey fellas. i have an iphone 4s. when i use the cable which i got with the box, it doesn't work. i have to try different dimensions of jack and at some point, it starts working. and then if phone is moved, charging will be disconnected. i guess its a

  • Flagging a variant by a feild value based on char,value.

    Hello SAP Gurus, I have a requirement in which I have to flag a variant based on characteristic values. During configuration, when you happen to select certain characteristic values in  a character, the material should flag with a character material

  • Disable Pagma and Cache-Control headers in SunOne WebServer 6.1

    Hi, I want the [Pragma] and [Cache-Control] headers completely disappear from SunOne WebServer 6.1 JSP responses (like the SunOne WebServer 6.0 SP8, http/1.1 but no [Pragma] and [Cache-Control] headers), can I achieve this? Thanks, Harry

  • How to sync bluetooth iphone 4 to windows 7

    How do i SYNC via bluetooth my I phone 4 to windows 7?