Re: Array of Objects

From: Sudsy (bitbucket44_at_hotmail.com)
Date: 02/16/04


Date: Sun, 15 Feb 2004 19:37:24 -0500

Sitaram wrote:
<snip>
> class t1
> {
> public static int x;
       public int x;
> public static String y;
       public String y;
>
> public static void pushin(int p)
   public void pushin(int p)
> {
> x=p;
> }
> public static void pusht(String p)
   public void pusht(String p)
> {
> y=p;
> }
> public void disp()
> {
> System.out.println(x);
> System.out.println(y);
> }
> };
<snip>

By making the methods and variables static you're saying that
they have class scope rather than instance scope. Make the
changes listed above and the results will be what you expect.



Relevant Pages

  • Re: Threads - synchronization
    ... and ThDbut not in ThA() and ThB()? ... public void ThA() ...
    (comp.lang.java.programmer)
  • Re: problem using thread
    ... > public void run ... methods in superclasses with new implementations in the subclasses. ... As you make an instance of db, the call to "run" will only execute the ...
    (comp.lang.java.programmer)
  • Re: Generic Interface and casting from object at runtime problem
    ... Anthony Paul wrote: ... Okay, so here's the problem... ... public void DoSomething ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: synchronized statements
    ... John Thorner wrote: ... > synchronizedwithout any luck. ... > public void run{ ...
    (comp.lang.java.programmer)
  • im still here ...
    ... public void paintComponent{ ... public static String setAlarm(String theAlarm,String theTime){ ...
    (comp.lang.java.help)