3

Note:

C:\Users\Greg\Documents\NetBeansProjects\abalon3\build\generated\src\org\apache\jsp\user2_jsp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Code:

<%
  String like=" ";
  Vector<String> vcd = new Vector<String>();
  Vector<String> vbo = new Vector<String>();
  vcd=CheckUser.search_latest_cd();
  int jc=vcd.size();
  vbo=CheckUser.search_latest_books();
  int jb=vbo.size();
  int i=0;

%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<table border="1" cellspacing="10"
bgcolor=#99FFFF>
<tr>
<th>Author</th>
<th>Title</th>
<th>Summary</th>
<th>Genre</th>
<th>year</th>
<th>Price</th>
<th>ID</th>
</tr>
<%if(vbo.size()>0){for( i=jb;i<jb;i-=7){%>
<tr><td><%out.print(vbo.get(i-6));%></td><td><%out.print(vbo.get(i-5));%></td>
<td><%out.print(vbo.get(i-4));%></td><td><%out.print(vbo.get(i-3));%></td>
<td><%out.print(vbo.get(i-2));%></td><td><%out.print(vbo.get(i-1));%></td>
<td><%out.print(vbo.get(i));}}%></td></tr>
</table>

can anyone tell me where's the problem?

Asaph
  • 147,774
  • 24
  • 184
  • 187
user618843
  • 31
  • 1

3 Answers3

1

Try doing what the message says:

Recompile with -Xlint:unchecked for details.

Zian Choy
  • 2,738
  • 4
  • 30
  • 62
1

Do vcd=CheckUser.search_latest_cd(); and vbo=CheckUser.search_latest_books(); return Vector<String>?

The cause for unchecked or unsafe operations is generally that the compiler cannot check the generictype. Read here for more detials.

Also, Java Vector is deprecated in the later version of JVM. You should consider using List and ArrayList

Another note, you do not need to create an object which never be used. Here is your code:

Vector<String> vcd = new Vector<String>();
vcd=CheckUser.search_latest_cd();

You can set the object directly to vcd:

Vector<String> vcd = CheckUser.search_latest_cd();

or

Vector<String> vcd = null;
vcd=CheckUser.search_latest_cd();

Creating new Vector object which is never be used is a waste of time.

Community
  • 1
  • 1
gigadot
  • 8,743
  • 7
  • 33
  • 49
0

And last but not least, what you're seeing is not an error but a warning from the compiler (though some compilers can be set up to handle warnings as errors, this isn't the default behavior of the Sun Java compiler).

jwenting
  • 4,890
  • 2
  • 22
  • 28