943,694 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 601
  • Java RSS
Sep 27th, 2007
0

Precasting in java

Expand Post »
What is mean by precasting in java can any one give me simple example please...
Similar Threads
Reputation Points: 119
Solved Threads: 7
Practically a Posting Shark
vinod_javas is offline Offline
871 posts
since Feb 2007
Sep 27th, 2007
0

Re: Precasting in java

Not sure exactly what you are referring to with "precasting". There is casting
Java Syntax (Toggle Plain Text)
  1. List pointList = new ArrayList();
  2. pointList.add( new Point(0,0) );
  3. Point p = (Point)pointList.get(0); // you must cast Object to Point here
or you can use generics to "pre-cast" and declare the type of collection
Java Syntax (Toggle Plain Text)
  1. List<Point> pointList = new ArrayList<Point>();
  2. pointList.add( new Point(0,0) );
  3. Point p0 = pointList.get(0); // no need for the cast here
Is that what you are wondering about?
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 838
Posting Genius
Ezzaral is offline Offline
6,757 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: visualization
Next Thread in Java Forum Timeline: Want help for Dijkstra algorithm





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC