Precasting in java

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2007
Posts: 871
Reputation: vinod_javas is an unknown quantity at this point 
Solved Threads: 7
vinod_javas's Avatar
vinod_javas vinod_javas is offline Offline
Practically a Posting Shark

Precasting in java

 
0
  #1
Sep 27th, 2007
What is mean by precasting in java can any one give me simple example please...
Adios,

Vinod......
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,492
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 519
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: Precasting in java

 
0
  #2
Sep 27th, 2007
Not sure exactly what you are referring to with "precasting". There is casting
  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
  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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC