Discussion: private final static vs public final static

take following class variable:public final static int constant = 1;Is there any harm in making this variable public if it's not used (and never will be) in any other class?
Under the same assumption Is there any point in making this variable static?
tx for your input

Is there any harm in making this variablepublic
if it's not used (and never will
be) in any other class?Harm? No. Use? Neither.I suppose it makes no difference at all concerning
runtime performance?
Under the same assumption Is there any point inmaking this variable
static?If the creation of the constant is costly, for
instance. A logger is private final static most of
the time.Same here, does making a variable final or static
have any influence on runtime performance?No. And for 'expensive' operations (say, parsing a XML configuration file, which only needs to occur once), making a variable static will improve performance.
- Saish

Similar Messages

  • How to javadoc "public final static int"?

    How can we create "Field Summary" HTML document for "public final static int" variables?
    This question is probably same as the below question.
    http://forums.java.sun.com/thread.jsp?forum=41&thread=72832
    p.s.
    The below document indicates CENTER, NORTH, ...
    How an we achieve it to document "public final static" variables?
    http://java.sun.com/products/jdk/1.2/docs/api/index.html

    No, 1.3 does not have the static constant values exposed to the Doclet API,
    and so that information is not available to any doclets to place in the
    generated documentation.
    BTW, based on feedback from a developer, we changed the format from:
    public static final int NORTH = 0
    to
    public static final int NORTH
    See: Constant values
    where the "Constant values" link takes them to a summary page that
    lists all of the values. This helps discourage users from mistakenly
    seeing and using the value instead of the constant.
    -Doug Kramer
    Javadoc team

  • Private,public and static variable

    I am just not able to understand the use of declaring the variable as private.Because even if i declare the variable as public ,other user of the same application anyway will never be acess that variable !! Can someone clear my doubt.
    Also can some one tell me when can I declare a variable as static...that is ideallly when should i declare a variable as static (and for that matter private and public )
    Thanks.
    Tha

    Hi,
    There are some rules for variable declarations:
    Only the containing class and its inner classes can access private variables.
    Every class can access public variables.
    All classes in the same package can access protected variables.
    Imagine you're writing a program for archiving all your CD's.
    If you want to know how many cd's you have got you simply read the static variable.
    public class CD {
    private String name, author;
    public static int cdCount = 0;
    public CD(String name, String author){
    //do something to initialize
    cdCount++; //Increase the value, because a new CD has been created.
    public static int getCDCount(){      //static methods can be accessed without creating instances of classes
    return cdCount;
    public static void main(String[] args){
    CD kravitz = new CD("Lenny Kravitz", "A Song");
    CD britney = new CD("Britney Spears", "Another Song");
    System.out.println("You have " CD.getCDCount() " CDs"); //You call static methods on the class (you can also call them on instances, but it is important that you do not need to create a object of that class)
    }

  • ASA 5510 Multiple Public IP - Static NAT Issue - Dynamic PAT - SMTP

    Running into a little bit of a roadblock and hoping someone can help me figure out what the issue is.  My guess right now is that it has something to do with dynamic PAT.
    Essentially, I have a block of 5 static public IP's.  I have 1 assigned to the interface and am using another for email/webmail.  I have no problems accessing the internet, receving emails, etc...  The issue is that the static NAT public IP for email is using the outside IP instead of the one assigned through the static NAT.  I would really appreciate if anyone could help shed some light as to why this is happening for me.  I always thought a static nat should take precidence in the order of things.
    Recap:
    IP 1 -- 10.10.10.78 is assigned to outside interface.  Dynamic PAT for all network objects to use this address when going out.
    IP 2 -- 10.10.10.74 is assgned through static nat to email server.  Email server should respond to and send out using this IP address.
    Email server gets traffic from 10.10.10.74 like it is supposed to, but when sending out shows as 10.10.10.78 instead of 10.10.10.74.
    Thanks in advance for anyone that reads this and can lend a hand.
    - Justin
    Here is my running config (some items like IP's, domain names, etc... modified to hide actual values; ignore VPN stuff -- still work in progress):
    ASA Version 8.4(3)
    hostname MYHOSTNAME
    domain-name MYDOMAIN.COM
    enable password msTsgJ6BvY68//T7 encrypted
    passwd msTsgJ6BvY68//T7 encrypted
    names
    interface Ethernet0/0
    speed 100
    duplex full
    nameif outside
    security-level 0
    ip address 10.10.10.78 255.255.255.248
    interface Ethernet0/1
    nameif inside
    security-level 100
    ip address 192.168.2.2 255.255.255.0
    interface Ethernet0/2
    shutdown
    no nameif
    no security-level
    no ip address
    interface Ethernet0/3
    shutdown
    no nameif
    no security-level
    no ip address
    interface Management0/0
    nameif management
    security-level 100
    ip address 192.168.1.1 255.255.255.0
    management-only
    boot system disk0:/asa843-k8.bin
    ftp mode passive
    clock timezone CST -6
    clock summer-time CDT recurring
    dns server-group DefaultDNS
    domain-name MYDOMAIN.COM
    same-security-traffic permit inter-interface
    same-security-traffic permit intra-interface
    object network obj_any
    subnet 0.0.0.0 0.0.0.0
    object network inside-network
    subnet 192.168.2.0 255.255.255.0
    object network Email
    host 192.168.2.7
    object network Webmail
    host 192.168.2.16
    object network WebmailSecure
    host 192.168.2.16
    access-list inside_access_out extended permit ip any any
    access-list inside_access_out extended permit icmp any any
    access-list VPN_Split_Tunnel_List remark The corporate network behind the ASA (inside)
    access-list VPN_Split_Tunnel_List standard permit 192.168.2.0 255.255.255.0
    access-list outside_access_in extended deny icmp any any
    access-list outside_access_in extended permit tcp any object Email eq smtp
    access-list outside_access_in extended permit tcp any object Webmail eq www
    access-list outside_access_in extended permit tcp any object WebmailSecure eq https
    pager lines 24
    logging asdm informational
    mtu outside 1500
    mtu inside 1500
    mtu management 1500
    icmp unreachable rate-limit 1 burst-size 1
    asdm image disk0:/asdm-647.bin
    asdm history enable
    arp timeout 14400
    nat (inside,outside) source static inside-network inside-network destination static inside-network inside-network no-proxy-arp route-lookup
    object network obj_any
    nat (inside,outside) dynamic interface
    object network Email
    nat (inside,outside) static 10.10.10.74 service tcp smtp smtp
    object network Webmail
    nat (inside,outside) static 10.10.10.74 service tcp www www
    object network WebmailSecure
    nat (inside,outside) static 10.10.10.74 service tcp https https
    access-group outside_access_in in interface outside
    access-group inside_access_out out interface inside
    route outside 0.0.0.0 0.0.0.0 10.10.10.73 1
    timeout xlate 3:00:00
    timeout pat-xlate 0:00:30
    timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 icmp 0:00:02
    timeout sunrpc 0:10:00 h323 0:05:00 h225 1:00:00 mgcp 0:05:00 mgcp-pat 0:05:00
    timeout sip 0:30:00 sip_media 0:02:00 sip-invite 0:03:00 sip-disconnect 0:02:00
    timeout sip-provisional-media 0:02:00 uauth 0:05:00 absolute
    timeout tcp-proxy-reassembly 0:01:00
    timeout floating-conn 0:00:00
    dynamic-access-policy-record DfltAccessPolicy
    aaa-server MYDOMAIN protocol kerberos
    aaa-server MYDOMAIN (inside) host 192.168.2.8
    kerberos-realm MYDOMAIN.COM
    aaa-server MYDOMAIN (inside) host 192.168.2.9
    kerberos-realm MYDOMAIN.COM
    aaa-server MY-LDAP protocol ldap
    aaa-server MY-LDAP (inside) host 192.168.2.8
    ldap-base-dn DC=MYDOMAIN,DC=com
    ldap-group-base-dn DC=MYDOMAIN,DC=com
    ldap-scope subtree
    ldap-naming-attribute sAMAccountName
    ldap-login-password *****
    ldap-login-dn CN=SOMEUSER,CN=Users,DC=MYDOMAIN,DC=com
    server-type microsoft
    aaa-server MY-LDAP (inside) host 192.168.2.9
    ldap-base-dn DC=MYDOMAIN,DC=com
    ldap-group-base-dn DC=MYDOMAIN,DC=com
    ldap-scope subtree
    ldap-naming-attribute sAMAccountName
    ldap-login-password *****
    ldap-login-dn CN=SOMEUSER,CN=Users,DC=MYDOMAIN,DC=com
    server-type microsoft
    user-identity default-domain LOCAL
    http server enable
    http 192.168.1.0 255.255.255.0 management
    http 192.168.2.0 255.255.255.0 inside
    http redirect outside 80
    no snmp-server location
    no snmp-server contact
    snmp-server enable traps snmp authentication linkup linkdown coldstart
    crypto ipsec ikev1 transform-set ESP-3DES-SHA esp-3des esp-sha-hmac
    crypto ipsec ikev1 transform-set ESP-AES-256-MD5 esp-aes-256 esp-md5-hmac
    crypto ipsec ikev1 transform-set ESP-DES-SHA esp-des esp-sha-hmac
    crypto ipsec ikev1 transform-set ESP-DES-MD5 esp-des esp-md5-hmac
    crypto ipsec ikev1 transform-set ESP-AES-192-MD5 esp-aes-192 esp-md5-hmac
    crypto ipsec ikev1 transform-set ESP-3DES-MD5 esp-3des esp-md5-hmac
    crypto ipsec ikev1 transform-set ESP-AES-256-SHA esp-aes-256 esp-sha-hmac
    crypto ipsec ikev1 transform-set ESP-AES-128-SHA esp-aes esp-sha-hmac
    crypto ipsec ikev1 transform-set ESP-AES-192-SHA esp-aes-192 esp-sha-hmac
    crypto ipsec ikev1 transform-set ESP-AES-128-MD5 esp-aes esp-md5-hmac
    crypto ipsec ikev2 ipsec-proposal AES256
    protocol esp encryption aes-256
    protocol esp integrity sha-1 md5
    crypto ipsec ikev2 ipsec-proposal AES192
    protocol esp encryption aes-192
    protocol esp integrity sha-1 md5
    crypto ipsec ikev2 ipsec-proposal AES
    protocol esp encryption aes
    protocol esp integrity sha-1 md5
    crypto ipsec ikev2 ipsec-proposal 3DES
    protocol esp encryption 3des
    protocol esp integrity sha-1 md5
    crypto ipsec ikev2 ipsec-proposal DES
    protocol esp encryption des
    protocol esp integrity sha-1 md5
    crypto dynamic-map SYSTEM_DEFAULT_CRYPTO_MAP 65535 set pfs group1
    crypto dynamic-map SYSTEM_DEFAULT_CRYPTO_MAP 65535 set ikev1 transform-set ESP-AES-128-SHA ESP-AES-128-MD5 ESP-AES-192-SHA ESP-AES-192-MD5 ESP-AES-256-SHA ESP-AES-256-MD5 ESP-3DES-SHA ESP-3DES-MD5 ESP-DES-SHA ESP-DES-MD5
    crypto dynamic-map SYSTEM_DEFAULT_CRYPTO_MAP 65535 set ikev2 ipsec-proposal AES256 AES192 AES 3DES DES
    crypto map outside_map 65535 ipsec-isakmp dynamic SYSTEM_DEFAULT_CRYPTO_MAP
    crypto map outside_map interface outside
    crypto map inside_map 65535 ipsec-isakmp dynamic SYSTEM_DEFAULT_CRYPTO_MAP
    crypto map inside_map interface inside
    crypto ca trustpoint ASDM_TrustPoint0
    enrollment self
    email [email protected]
    subject-name CN=MYHOSTNAME
    ip-address 10.10.10.78
    proxy-ldc-issuer
    crl configure
    crypto ca certificate chain ASDM_TrustPoint0
    certificate e633854f
        30820298 30820201 a0030201 020204e6 33854f30 0d06092a 864886f7 0d010105
        0500305e 31143012 06035504 03130b47 46472d53 55532d41 53413146 301a0609
        2a864886 f70d0109 08130d39 382e3130 302e3232 322e3738 30280609 2a864886
        f70d0109 02161b47 46472d53 55532d41 53412e47 46472d50 4541424f 44592e43
        4f4d301e 170d3132 30343131 30373431 33355a17 0d323230 34303930 37343133
        355a305e 31143012 06035504 03130b47 46472d53 55532d41 53413146 301a0609
        2a864886 f70d0109 08130d39 382e3130 302e3232 322e3738 30280609 2a864886
        f70d0109 02161b47 46472d53 55532d41 53412e47 46472d50 4541424f 44592e43
        4f4d3081 9f300d06 092a8648 86f70d01 01010500 03818d00 30818902 818100b4
        aa6e27de fbf8492b 74ba91aa e0fd8361 e0e85a31 f95c380d 6e5f43ac a695a810
        f50e893b 82b91870 a32f7e38 8f392607 7a69c814 36a71a9c 2dccca07 24fe7f88
        0f3451ed c64e85fc 8359c87e 62ebf166 0a570ac5 f9f1c64b 262eca66 ea05ab65
        78da1ac2 9867a115 b14a6ba1 cd82d04e 00fc6557 856f7c04 ab1b08a0 b9de8b02
        03010001 a3633061 300f0603 551d1301 01ff0405 30030101 ff300e06 03551d0f
        0101ff04 04030201 86301f06 03551d23 04183016 801430cf 97ef92bb 678e3ba3
        0002069c 8130550a 2664301d 0603551d 0e041604 1430cf97 ef92bb67 8e3ba300
        02069c81 30550a26 64300d06 092a8648 86f70d01 01050500 03818100 64c403bd
        d75717ab 24383e77 63e10ba7 4fdef625 73c5a952 19ceecbd 75bd23ca 86dc0298
        e6693a8a 2c7fb85f 096497a7 8d784ada a433ee0d d88e9219 f0615f3c 7814bf1c
        5b4fe847 7d8894eb 18fe2da7 05f15ae9 bc2c17ec 3a7831ee f95d6ced 4799fba2
        781c8228 48224843 dc07ebb5 d20abf2a b68cfa62 ac71a41b 1196a018
      quit
    crypto ikev2 policy 1
    encryption aes-256
    integrity sha
    group 5 2
    prf sha
    lifetime seconds 86400
    crypto ikev2 policy 10
    encryption aes-192
    integrity sha
    group 5 2
    prf sha
    lifetime seconds 86400
    crypto ikev2 policy 20
    encryption aes
    integrity sha
    group 5 2
    prf sha
    lifetime seconds 86400
    crypto ikev2 policy 30
    encryption 3des
    integrity sha
    group 5 2
    prf sha
    lifetime seconds 86400
    crypto ikev2 policy 40
    encryption des
    integrity sha
    group 5 2
    prf sha
    lifetime seconds 86400
    crypto ikev2 enable outside client-services port 443
    crypto ikev2 enable inside client-services port 443
    crypto ikev2 remote-access trustpoint ASDM_TrustPoint0
    crypto ikev1 policy 10
    authentication pre-share
    encryption 3des
    hash sha
    group 2
    lifetime 86400
    telnet 192.168.2.0 255.255.255.0 inside
    telnet 192.168.1.0 255.255.255.0 management
    telnet timeout 20
    ssh timeout 5
    console timeout 0
    management-access inside
    dhcpd address 192.168.1.2-192.168.1.254 management
    dhcpd enable management
    threat-detection basic-threat
    threat-detection statistics
    threat-detection statistics tcp-intercept rate-interval 30 burst-rate 400 average-rate 200
    ntp server 192.168.2.8 source inside prefer
    ssl trust-point ASDM_TrustPoint0 inside
    ssl trust-point ASDM_TrustPoint0 outside
    webvpn
    enable outside
    enable inside
    anyconnect-essentials
    anyconnect image disk0:/anyconnect-win-3.0.5080-k9.pkg 1
    anyconnect profiles VPN_client_profile disk0:/VPN_client_profile.xml
    anyconnect enable
    tunnel-group-list enable
    group-policy DfltGrpPolicy attributes
    vpn-tunnel-protocol ikev1 l2tp-ipsec
    group-policy GroupPolicy_VPN internal
    group-policy GroupPolicy_VPN attributes
    wins-server value 192.168.2.8 192.168.2.9
    dns-server value 192.168.2.8 192.168.2.9
    vpn-filter value VPN_Split_Tunnel_List
    vpn-tunnel-protocol ikev2 ssl-client
    group-lock value VPN
    split-tunnel-policy tunnelspecified
    split-tunnel-network-list value VPN_Split_Tunnel_List
    default-domain value MYDOMAIN.COM
    webvpn
      anyconnect profiles value VPN_client_profile type user
    group-policy GroupPolicy-VPN-LAPTOP internal
    group-policy GroupPolicy-VPN-LAPTOP attributes
    wins-server value 192.168.2.8 192.168.2.9
    dns-server value 192.168.2.8 192.168.2.9
    vpn-filter value VPN_Split_Tunnel_List
    vpn-tunnel-protocol ikev2
    group-lock value VPN-LAPTOP
    split-tunnel-policy tunnelspecified
    split-tunnel-network-list value VPN_Split_Tunnel_List
    default-domain value MYDOMAIN.COM
    webvpn
      anyconnect profiles value VPN_client_profile type user
    tunnel-group VPN type remote-access
    tunnel-group VPN general-attributes
    authentication-server-group MYDOMAIN
    default-group-policy GroupPolicy_VPN
    dhcp-server 192.168.2.8
    dhcp-server 192.168.2.9
    dhcp-server 192.168.2.10
    tunnel-group VPN webvpn-attributes
    group-alias VPN enable
    tunnel-group VPN-LAPTOP type remote-access
    tunnel-group VPN-LAPTOP general-attributes
    authentication-server-group MY-LDAP
    default-group-policy GroupPolicy-VPN-LAPTOP
    dhcp-server 192.168.2.8
    dhcp-server 192.168.2.9
    dhcp-server 192.168.2.10
    tunnel-group VPN-LAPTOP webvpn-attributes
    class-map inspection_default
    match default-inspection-traffic
    policy-map type inspect dns preset_dns_map
    parameters
      message-length maximum client auto
      message-length maximum 512
    policy-map global_policy
    class inspection_default
      inspect dns preset_dns_map
      inspect ftp
      inspect h323 h225
      inspect h323 ras
      inspect rsh
      inspect rtsp
      inspect sqlnet
      inspect skinny 
      inspect sunrpc
      inspect xdmcp
      inspect sip 
      inspect netbios
      inspect tftp
      inspect ip-options
    class class-default
      user-statistics accounting
    service-policy global_policy global
    prompt hostname context
    no call-home reporting anonymous
    hpm topN enable
    Cryptochecksum:951faceacf912d432fc228ecfcdffd3f

    Hi ,
    As per you config :
    object network obj_any
    nat (inside,outside) dynamic interface
    object network Email
    nat (inside,outside) static 10.10.10.74 service tcp smtp smtp
    object network Webmail
    nat (inside,outside) static 10.10.10.74 service tcp www www
    object network WebmailSecure
    nat (inside,outside) static 10.10.10.74 service tcp https https
    object network obj_any
    subnet 0.0.0.0 0.0.0.0
    object network inside-network
    subnet 192.168.2.0 255.255.255.0
    object network Email
    host 192.168.2.7
    object network Webmail
    host 192.168.2.16
    object network WebmailSecure
    host 192.168.2.16
    The flows from email server ( 192.168.2.7 ) , will be NATed to 10.10.10.74, only if the source port is TCP/25. Any other souce port will use the interface IP for NAT.
      Are you saying that this is not happening ?
    Dan

  • Does "public final MainClass  " work or not?

    As i declare my main class which has main method as public final Mainclass,what happen???

    Chicon wrote:
    Hi makpandian,
    Nothing special. You simply make MainClass immutable. That means you can't build another class that extends MainClass.
    Its main method will work.Please note that "immutable" means you can't change its internal state and has nothing to do with whether a class is final or not.

  • Non Static Variable addressed to Static Variable

    Hi,
    I am new to java, I am getting (Non Static Variable sb,serverAddress addressed to Static Variable)
    Here is the code. Thanks for reading, any help or explanation would be appreciated-
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package webcheck;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;
    import java.net.MalformedURLException;
    import java.net.ProtocolException;
    import java.net.URL;
    * @author
    public class checkhttp {
          private URL serverAddress = null;
          private StringBuilder sb = null;
          public checkhttp(java.net.URL serverAddress,java.lang.StringBuilder StringBuilder)
              this.serverAddress=serverAddress;
              this.sb=sb;
      public static void main(String[] args) {
          HttpURLConnection connection = null;
          OutputStreamWriter wr = null;
          BufferedReader rd  = null;
          String line = null;
          int x;
          //checkhttp check= new checkhttp();
          try {
              serverAddress = new URL("http://www.yahoo.com");
              //set up out communications stuff
              connection = null;
              //Set up the initial connection
              connection = (HttpURLConnection)serverAddress.openConnection();
              connection.setRequestMethod("GET");
              connection.setDoOutput(true);
              connection.setReadTimeout(10000);
              connection.connect();
              //get the output stream writer and write the output to the server
              //wr = new OutputStreamWriter(connection.getOutputStream());
              //wr.write("");
              //wr.flush();
              //read the result from the server
              rd  = new BufferedReader(new InputStreamReader(connection.getInputStream()));
              sb = new StringBuilder();
              while ((line = rd.readLine()) != null)
                  sb.append(line + '\n');
              System.out.println(sb.toString());
              System.out.println("Server is up");
          } catch (MalformedURLException e) {
              e.printStackTrace();
          } catch (ProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          finally
              //close the connection, set all objects to null
              connection.disconnect();
              //rd = null;
              //sb = null;
              //wr = null;
              connection = null;
    }

    Someone please correct me if I'm wrong, but since main is static, any fields it access must also be static.
    The static keyword declares that something is accessable no matter the class state, thus you can call main() and run your program without having something make an instance of the object that your progam defines. For example:
    class Foo {
          static public String strText = "Hello World";
    //Later in some method, this is valid.
    String MyString = Foo.strText;
    //However, if strText was not static you need to
    Foo fooExample = new Foo();
    String myString = fooExample.strText;Static should not override private, so static private fields/members are not accessable. To be accessable you still need to be public.
    Edited by: porpoisepower on Jan 21, 2010 2:18 PM

  • How to reference a static variable before the static initializer runs

    I'm anything but new to Java. Nevertheless, one discovers something new ever' once n a while. (At least I think so; correct me if I'm wrong in this.)
    I've long thought it impossible to reference a static variable on a class without the class' static initializer running first. But I seem to have discovered a way:
    public class Foo  {
      public static final SumClass fooVar;  // by default initialized to null
      static  {
         fooVar = new SumClass();
    public class Bar  {
      public static final SumClass barVar;
      static  {
         barVar = Foo.fooVar;  // <<<--- set to null !
    }Warning: Speculation ahead.
    Normally the initial reference to Foo would cause Foo's class object to instantiate, initializing Foo's static variables, then running static{}. But apparently a static initializer cannot be triggered from within another static initializer. Can anyone confirm?
    How to fix/avoid: Obviously, one could avoid use of the static initializer. The illustration doesn't call for it.
    public class Foo  {
      public static final SumClass fooVar = new SumClass();  // either this ..
    public class Bar  {
      public static final SumClass barVar = Foo.fooVar;  // .. or this would prevent the problem
    }But there are times when you need to use it.
    So what's an elegant way to avoid the problem?

    DMF. wrote:
    jschell wrote:
    But there are times when you need to use it. I seriously doubt that.
    I would suppose that if one did "need" to use it it would only be once in ones entire professional career.Try an initializer that requires several statements. Josh Bloch illustrates one in an early chapter of Effective Java, IIRC.
    Another classic usage is for Singletons. You can make one look like a Monostate and avoid the annoying instance() invocation. Sure, it's not the only way, but it's a good one.
    What? You only encounter those once in a career? We must have very different careers. ;)
    So what's an elegant way to avoid the problem? Redesign. Not because it is elegant but rather to correct the error in the design.<pff> You have no idea what my design looks like; I just drew you a couple of stick figures.If it's dependent on such things as when a static initializer runs, it's poor. That's avoidable. Mentioning a case where such a dependency is used, that's irrelevant. It can be avoided. I know this is the point where you come up with a series of unfortunate coincidences that somehow dictate that you must use such a thing, but the very fact that you're pondering the problem with the design is a design problem. By definition.
    Besides, since what I was supposing to be a problem wasn't a problem, your "solution" isn't a solution. Is it?Well, you did ask the exact question "So what's an elegant way to avoid the problem?". If you didn't want it answered, you should have said so. I'm wondering if there could be any answer to that question that wouldn't cause you to respond in such a snippy manner. Your design is supposedly problematic, as evidenced by your question. I fail to see why the answer "re-design" is unacceptable. Maybe "change the way the Java runtime initializes classes" would have been better?
    This thread is bizarre. Why ask a question to which the only sane answer, you have already ruled out?

  • To static or not to static

    Hello, i have a little discussion with a colleage of mine about the use of statics.
    say we have a class (sqlManager) which is used to do all the sql work including the db connection.
    would it be wise to make this class static. in my opinion no. perhaps make it a singleton, but not static.
    My colleage thinks otherwise, make it static i do not need an object of it. it makes it easier to code and smaller.. perhaps this is true, i personally find it ugly. any suggestions.
    Maqish

    I think if in the constructor method there are
    important things to be executed, then the singleton
    pattern will be better. Otherwise, the static
    solution is better.There's always a static initializer (static { .. }) for static classes that have the same basic role for static content as constructors do for instance content. Not playing favorites, just pointing it out for any future readers.
    If you are sure that the class has features that make
    this class immutable, that is, probably it never
    will be necessary to inherit the class because of its
    characteristics, then you may declare its methods as
    final and static.Inheritability is definitely a major factor.
    This doubt is only about the architecture of the
    application, that is, about its features, that must
    be analized to decide what kind of class has to be
    developed.As mentioned, I think a good general rule is that if you need singleton behavior, use a singleton. If you just need some utility methods, use static methods.

  • Accessing a private variable from a public method of the same class

    can anyone please tell me how to access a private variable, declared in a private method from a public method of the same class?
    here is the code, i'm trying to get the variable int[][][] grids.
    public static int[][] generateS(boolean[][] constraints)
      private static int[][][] sudokuGrids()
        int[][][] grids; // array of arrays!
        grids = new int[][][]
        {

    Are you sure that you want to have everything static here? You're possibly throwing away all the object-oriented goodness that java has to offer.
    Anyway, it seems to me that you can't get to that variable because it is buried within a method -- think scoping rules. I think that if you want to get at that variable your program design may be under the weather and may benefit from a significant refactoring in an OOP-manner.
    If you need more specific help, then ask away, but give us more information please about what you are trying to accomplish here and how you want to do this. Good luck.
    Pete
    Edited by: petes1234 on Nov 16, 2007 7:51 PM

  • Static method or non-static method

    hi,
    i was wondering would making a method static gain any efficiency (in J2ME)- obviously the method wont use any instance variables / methods.
    thanks.

    Guess what? It depends...
    You may think of implementing a Singleton pattern (see Gamma, GoF...) that goes like this:
    public class MySingleton {
        private static MySingleton instance;
        // constructor
        private MySingleton() {
        // getInstance method
        public static MySingleton getInstance() {
            if(instance == null)
                instance = new MySingleton();
            return instance;
        // further code
    }This pattern makes sure you will only have one instance of that class. See also the "WorkFlow Application Example: DeliveryMIDlet" from the NOKIA Forum. (http://www.microjava.com/articles/techtalk/workflow)

  • Dynamic call of a static method of an static attribute

    Hi all,
    is it possible to call dynamically a static method of a static attribute of a class.
    The statement without dynamic call would look like this:
    cl_test_class=>static_attribute=>static_method( ).
    I would like to do it like this:
    ('CL_TEST_CLASS')=>static_attribute=>static_method( ).
    Netiher the one nor the other way works for me - I'm getting the error "The notation used is reserved for business object classes".
    Regards, Stefan

    I guess, it is not possible to call method using the short form (parameters in brackets) is not possible in Dynamic Access. You may need to get the attribute first and then call the method.
    CLASS lcl_main DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA: o_same TYPE REF TO lcl_main.
        METHODS: run.
    ENDCLASS.                    "lcl_main DEFINITION
    CLASS lcl_main IMPLEMENTATION.
      METHOD run.
        WRITE: 'success'.
      ENDMETHOD.                    "run
    ENDCLASS.                    "lcl_main IMPLEMENTATION
    START-OF-SELECTION.
      DATA: lo_same TYPE REF TO lcl_main.
      CREATE OBJECT lcl_main=>o_same.
    *  lcl_main=>o_same=>run( ).
      TRY.
          FIELD-SYMBOLS: <fs> TYPE REF TO lcl_main.
          ASSIGN ('LCL_MAIN')=>('O_SAME') TO <fs>.
          CALL METHOD <fs>->('RUN').
        CATCH cx_root.
      ENDTRY.
    Regards,
    Naimesh Patel

  • User Contributed Tips in Final Cut Express and Final Cut Express HD Forum

    *The following User Contributed Tips are located in the Pro Applications: Video > Final Cut Express and Final Cut Express HD Forum:*
    skalicki` - Working with AVCHD: Log and Transfer FAQs
    http://discussions.apple.com/thread.jspa?threadID=2672530
    Publish date: December 03, 2010
    skalicki` - Final Cut Express: Basic Troubleshooting
    http://discussions.apple.com/thread.jspa?threadID=2662419
    Publish date: November 26, 2010
    *The following related tips are located in other areas of Apple Discussions:*
    Please see the User Tips Library

    I'm relatively new to FCE myself, so I'll answer with what I know. I'm sure the more experienced folks will either add to or correct what I say.
    1) For the Inconvenient Truth thing, I believe this would best be done in LiveType, which does allow you to do animations, and to work on individual letters and characters. Whether or not it could exactly reproduce the effects in the clip, I'm not certain, but I'm sure it could come very close.
    2) For the Crowd or the Cross effects, there are two things going on at once: effects on the text, and effects on the video. My gut feeling is that both FCE and LiveType can do these, with lots of work and patience, but I'll defer to other people to answer.
    3) The page peel is a transition built into FCE.

  • Final Cut Pro to Final Cut Express -- Format issues?

    Hi,
    I'm shooting a project on a Panasonic HVX-200A, and my cameraman is going to import the footage to his Final Cut Pro station. He's then going to transfer the FCP footage and data over to an external hard drive, which I am going to use to edit the film using Final Cut Express.
    Will there be any formatting issues if I bring the data from Final Cut Pro to Final Cut Express?
    Thanks!!
    Sameer Ketkar

    Clip files can be easily imported into FCE if they are QuickTime DV-NTSC/DV-PAL or Apple Intermediate Codec (720p30, 1080i50/60). If they are other formats/codecs they should be converted to DV or AIC before importing into FCE.
    FCPro project files cannot be imported into FCExpress.
    I'd suggest a trial run before committing the project to this workflow.

  • Final cut express to final cut pro x ?

    Is it possible to move my films from Final Cut Express to Final Cut Pro X ?

    Luis Sequeira1 wrote:
    a possible route might envolve going through Final Cut 7, and 7toX, if indeed FC7 can import FCE projects, I don't know; but that would be at least awkward if it worked at all)
    Yes, it works…
    Russ

  • Upgrade from Final Cut Express to Final Cut Pro

    Is there an upgrade path from Final Cut Express to Final Cut Pro?

    Why do you want to upgrade?
    Are there some features you particularly need?

Maybe you are looking for

  • Skip_unusable_indexes and primary keys

    Hi, if have data for a big table splitted in multipe files which i want to load via sqlldr all in the same table as fast as possible. The indexes should be rebuild after the last file was loaded. So I use  SKIP_UNUSABLE_INDEXES=TRUE,SKIP_INDEX_MAINTE

  • Inbound SD billing document IDOC

    Hi, We are trying to automate billing document creation in SAP based on the file extracted from external project management system. Is there any existing Inbound SD invoice IDOC? I know there is INVOIC02, however I think it is more often used for Out

  • Portal on VMS.. Help

    Our 8i version (8.1.6) on VMS does not have the JServer installed. We seem to be getting errors (in install.log) related to java.lang. packages during installation. The error we get tring to log on is "Proxy Log on Failed" Question . Is Jserver requi

  • Upgrading 32 bit Vista to 64 bit Windows 7?

    I bought a T500 laptop with 32 bit Vista business installed, now I am thinking to order a free upgrading  64 bit Windows 7 professional, dose anybody know it is possible? I know I need to do a fresh installation if I want a 64 bit windows 7 on a 32 b

  • Can i use it in my Mac

    Hello: I just got an airport extreme card from a friend and i tried to install it in my PowerBook G4,(15" 1Ghz black keyboard) someone were saying it works others it doesnt, i guess i need an adaptor or something, any help anyone. Cheers