tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Y Shiva <just_did_i...@yahoo.com>
Subject How can java do this
Date Fri, 28 Sep 2007 00:47:13 GMT
  import java.io.Serializable;
  public class Accomplice {
  
  /**
  * @param args
  */
  public static void main(String[] args) {
  // TODO Auto-generated method stub
  Data d=new Data();
  System.out.println(d.getS(4));
  System.out.println(Data.count);
  System.out.println(d.getS(3));
  System.out.println(Data.count);
  
  
  }
  
  }
  final class Data implements Serializable
  {
  public static int count=0;
  
  public Data()
  {
  Data.counter();
  }
  private static void counter()
  {
  count=count+1;
  if(count>=2)
  {
  s=null; 
  }
  }
  private static String s="abc";
  public String getS(int key)
  {
  if(key==3)
  {
  Data.counter();
  return s;
  }
  else
  {
  Data.counter();
  return "try again";
  }
  }
  
  }
  
Hi all see if you can hack to the Data i call it the tapeworm concept.
   
   
  Thanks 
  Regards
  Shivakanth


       
---------------------------------
Luggage? GPS? Comic books? 
Check out fitting  gifts for grads at Yahoo! Search.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message