About 50 results
Open links in new tab
  1. Global variables in Java - Stack Overflow

    Jan 10, 2011 · For example---random () method in Phrase-O-Matic app;it is a method should be callable from anywhere of a program. So in order to satisfy the things like Above "We need to have Global …

  2. java - Assign variable value inside if-statement - Stack Overflow

    Aug 15, 2016 · 1 Yes, it is possible to assign inside if conditional check. But, your variable should have already been declared to assign something.

  3. How to declare a constant in Java? - Stack Overflow

    Oct 9, 2012 · You can use an enum type in Java 5 and onwards for the purpose you have described. It is type safe. A is an instance variable. (If it has the static modifier, then it becomes a static variable.) …

  4. What is the correct way to declare a boolean variable in Java?

    Aug 1, 2016 · Further, we initialize the boolean variable to false to hold an initial default value which is false. In case you have declared it as instance variable, it will automatically be initialized to false. But, …

  5. Is it possible to declare a variable within a Java while conditional ...

    Aug 4, 2016 · But the variable still has to be declared outside the while-loop. So, as I want to keep my variable scopes clean, is it possible to declare a variable within the while conditional, or is there …

  6. java - Why is it possible to declare a variable without an initial ...

    Apr 1, 2017 · If you really look at what happens when you declare a variable and initialize it (assign an initial value), you will see that down at machine instruction level, or byte code for Java there is a …

  7. Defining a variable in IF statement (Java) - Stack Overflow

    Jul 22, 2017 · In Java, variables are defined inside scopes. As you have just experienced you can't use a variable that you have declared in the scope of the if block outside of the if block. What is defined …

  8. java - Declaring variables inside or outside of a loop - Stack Overflow

    Jan 10, 2012 · The scope of local variables should always be the smallest possible. In your example I presume str is not used outside of the while loop, otherwise you would not be asking the question, …

  9. Why do we declare Private variables in Java? - Stack Overflow

    Feb 16, 2018 · 4 "Private" variable means "controlled" access not "no" access. e.g. I can make the variable read-only by having only a getter method and no setter method. The owning class decides …

  10. java - Android Declare a Variable - Stack Overflow

    May 27, 2013 · I suggest learning Java fundamentals first. Declaring a variable is fundamental to Java programming language (and indeed many programming languages), its not just Android specific.