Recent Posts
HTML | 1 sec ago
None | 8 sec ago
T-SQL | 9 sec ago
Diff | 10 sec ago
None | 15 sec ago
PHP | 27 sec ago
C++ | 28 sec ago
None | 1 min ago
PHP | 1 min ago
None | 1 min ago
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Alexander on the 9th of Feb 2010 07:51:37 PM Download | Raw | Embed | Report
  1. public class Point
  2. {
  3.     /** Decleration of variables */
  4.     private int Id = 0; // the unique id for the instance of the class
  5.     static int counter = 0; // the counter of how many classes made
  6.     static List classList = new List(); // creates new list to store all the class instances
  7.     private double coord_x, coord_y;
  8.    
  9.     /**
  10.     Description: This constructor will run when new instance of this class is
  11.                  created and no values for x and u are specified
  12.     */
  13.     public Point()
  14.     {
  15.         this(0.0,0.0);
  16.     }
  17.    
  18.    
  19.     /**
  20.     Description: This constructor will run when new instance of this class is
  21.                  created and gets specified values for x and y
  22.     @param x (double), the value of x coordinate
  23.     @param y (double), the value of y coordinate
  24.     */
  25.     public Point(double x, double y)
  26.     {
  27.         this.coord_x = x;
  28.         this.coord_y = y;
  29.         classList.set(this.Id,this); // this is what i am trying to get to work
  30.         this.Id = this.counter++;
  31.     }
  32. }  
  33.  
  34. // i am trying to keep track of all classes so i can have a method within this class that will print all my x, y and the Id of the class
  35. // My idea was to add the refrence of the class to a list and then use for loop to print them all out.
  36.  
  37. //Error
  38. Point.java:47: cannot find symbol
  39. symbol  : variable This
  40. location: class Point
  41.         classList.set(this.Id,This);
  42.                               ^
  43. 1 error
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: