Search:

Type: Posts; User: TP-Oreilly

Search: Search took 0.07 seconds.

  1. Replies
    7
    Views
    1,767

    Re: Variable Scope

    Ok, thanks. So basically we use the static keyword for two reasons. 1. to make a variable have the same value across all instances and 2. to allow variables to be used without creating an instance of...
  2. Replies
    7
    Views
    1,767

    Re: Variable Scope

    I understand that the static keyword makes a variable have the same value across all instances, but I dont understand why when I put...


    import javax.swing.JOptionPane;
    public class Scope2 {
    ...
  3. Replies
    7
    Views
    1,767

    Re: Variable Scope

    If so, then why dont we make variables inside methods static also?
  4. Replies
    7
    Views
    1,767

    Re: Variable Scope

    So we make class variables a static variable so that we can use it without instantiating it?
  5. Replies
    7
    Views
    1,767

    Variable Scope

    Hi, can you answer me this.

    With class variables (a variable which is not declared in a body of any method), what are their scope?

    And why do I have to put "public static" in front of class...
Results 1 to 5 of 6