This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Compiler warnings

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I hope this topic is all right for this forum. It seems like something a beginner would see frequently.

I am working through Head First Java, and often get compiler warnings like those below when compiling the code listings downloaded from the book's web site. What are they saying? Better yet where can I find a list of warnings with understandable explanations?

C:\Documents and Settings\forest gump\My Documents\My Books
\HeadFirstJava\chapter-6\jwj\GameHelper.java:82:
warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
alphaCells.add(temp.concat(Integer.toString(row)));
^
C:\Documents and Settings\forest gump\My Documents\My Books
\HeadFirstJava\chapter-6\jwj\GameHelper.java:90:
warning: [unchecked] unchecked conversion
found : java.util.ArrayList
required: java.util.ArrayList<java.lang.String>
return alphaCells;
^
2 warnings

Tool completed successfully

I usually type in the code from the book, so I can get familiar with the syntax. A compile with only warnings is a delight to see.
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe what you are seeing is something specific to JSDK 1.5

In 1.5 you can use generics and specify what types should be in a Collection.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try adding the:
-source 1.4
switch when compiling and see if it goes away.
 
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Warnings let you know of potential problems, but they don't prevent the code from compiling.
 
James Jennings
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The warning was pointing to this expression:

ArrayList alphaCells = new ArrayList();

After doing some research, I changed it to:

ArrayList<String> alphaCells = new ArrayList<String>();

and the warnings go away. Apparently the code has not been updated from the 1st edition, which I assume was published before java 1.5 was released. Probably because some (many?) people have not updated from java 1.4.

P.S. I'm a (obsessive) perfectionist, Jeff.
P.P.S. Thanks for the speedy responses, everyone.
 
James Jennings
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just noticed that Head First Java, 2nd Edition book does have the java 1.5 code with the <String>, it is only the download files that not updated.
 
Are we home yet? Wait, did we forget the tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic