uncaught exception - Java [unchecked] unchecked case warning -
ok, i've been looking around , done alot of google searching, still can't find way avoid warning.
integer result = chooser.showopendialog(null); if (result.equals(0)) { string tempholder = chooser.getselectedfile().getpath(); filenameload = new file(tempholder); filenamesave = filenameload; fileinputstream fis = null; objectinputstream in = null; try { fis = new fileinputstream(filenameload); in = new objectinputstream(fis);; } catch(ioexception ex) { ex.printstacktrace(); } try { loadfile = (arraylist<dot>)in.readobject(); } catch(ioexception ex) { system.out.println("cast fail"); } catch(classnotfoundexception ex) { system.out.println("cast fail"); } catch (classcastexception ex) { system.out.println("cast fail"); } try { in.close(); } catch(exception ex) { system.out.println("failed close in"); } save.setenabled(true); gpanel.setdotlist(loadfile); } it gives me warning @ line loadfile = (arraylist)in.readobject(); i've added in catchs i'm not sure why still says uncatched. help? thanks?
it not "uncatched", "unchecked". jvm cannot tell @ runtime, i.e. when cast done, whether arraylist contains dot elements.
this warning occurs whenever cast raw type generic type. if sure cast ok, can suppress warning annotation
@suppresswarnings("unchecked") for this, encapsulate cast in small, separate method.
Comments
Post a Comment