| | |
Precasting in java
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Not sure exactly what you are referring to with "precasting". There is casting or you can use generics to "pre-cast" and declare the type of collection Is that what you are wondering about?
Java Syntax (Toggle Plain Text)
List pointList = new ArrayList(); pointList.add( new Point(0,0) ); Point p = (Point)pointList.get(0); // you must cast Object to Point here
Java Syntax (Toggle Plain Text)
List<Point> pointList = new ArrayList<Point>(); pointList.add( new Point(0,0) ); Point p0 = pointList.get(0); // no need for the cast here
![]() |
Similar Threads
- Java 3D Environment (Java)
- Java 3D (Java)
- Java Expert (Needed) (Java)
- Java Chat Reboots (Java)
Other Threads in the Java Forum
- Previous Thread: visualization
- Next Thread: Want help for Dijkstra algorithm
| Thread Tools | Search this Thread |
actuate android api applet application applications array arrays automation balls bank binary bluetooth business c++ chat class classes clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse error formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide image infinite ingres input integer intersect invokingapacheantprogrammatically j2me java javaprojects jni jpanel julia linux list loop looping map method methods mobile mysql netbeans newbie openjavafx parameter php print problem program programming project recursion repositories scanner screen scrollbar server set size sms sort sorting sql sqlserver state storm string sun superclass swing swt text-file threads tree windows






