About 30,900 results
Open links in new tab
  1. What are the differences between class variables and instance variables ...

    Aug 12, 2015 · Class variables maintain a single shared value for all instances of the class, even if no instance object of that class exists. You would use the static keyword to change an instance variable …

  2. Why shouldn't I be using public variables in my Java class?

    Nov 23, 2012 · A class can change the data type of a field, and users of the class do not need to change any of their code.he public methods are the access points to this class's fields from the outside java …

  3. object oriented - Why do we need private variables? - Software ...

    The goal of encapsulation is to make the external interface of the class explicit so that you know only these (typically) methods could have been used by others. Hence, private variables ensure that the …

  4. design - What are the considerations between a class variable and a ...

    Sep 21, 2022 · The term 'global variable' is pretty overloaded. In Python the term 'global' refers to module scope, for example. Java doesn't support a true 'global' nor does it refer to anything as such. …

  5. java - Using super keyword to access super class members - Software ...

    Dec 1, 2015 · Class C inherits class B so it will have two integer variables from B and one defined in itself. Now I can print the inherited super class variable i in class C through the display method and of …

  6. How does accessing class level variables in java work?

    Oct 16, 2016 · When you say usrStr = input.nextLine(); you are accessing the variable using the instance.staticVariable form. instance is implied. Java allows this; in the C# language, only the …

  7. Why doesn't Java automatically initialize local variables with its ...

    Nov 29, 2017 · so, obviously: Java doesn't initialize local primitive variables - although the default value false would be valuable. But why is that so, given that the default value of the type might be useful?

  8. java - Is a class with a high number of member variables bad and is ...

    Jun 9, 2020 · Context: Java, fairly new developer I have inherited code from a friend for a project that processes variables. The first thing i notice is the class has a ton of member variables.

  9. Are there any problems with using class variables in Java that can be ...

    Sep 8, 2018 · 3 So I've been coding in Java for a decent amount of time, but recently, I've started a class that cares about my coding design. In the past, if I had two methods inside a class that needed …

  10. java - Prefer class members or passing arguments between internal ...

    Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it ...