java Compilation
import java .util.*;
class ArrayListDemo
{
public static void main(String[] args)
{
ArrayList l=new ArrayList();
l.add("A");
l.add(10);
l.add(null);
System.out.println(l);
l.remove(2);
System.out.println(l);
l.add(2,"M");
l.add("N");
System.out.println(l);
}
}
in the above java program compilation time following error is occur in my system
Note: ArrayListDemo.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
so plz send me answer why this error is coming............
and what is the reason and solution ....
View Answers
July 30, 2012 at 10:19 AM
This comes up in Java 5 and later if you're using collections without type specifiers (e.g., Arraylist() instead of ArrayList<Object>()). It means that the compiler can't check that you're using the collection in a type-safe way, using generics.
To avoid this error, specify the type of object you're storing in the collection. So, specify the type as the following:
ArrayList<Object> l= new ArrayList<Object>();
In your code, you have added integer as well as string values to list therefore you need to use Object. Otherwise, whatever values you added, specify the type specifier.
Ads
Related Tutorials/Questions & Answers:
java Compilation
java program
compilation time following error is occur in my system
Note...
java Compilation import
java .util.*;
class ArrayListDemo... in
Java 5 and later if you're using collections without type specifiers (e.g.
java Compilation
java program
compilation time following error is occur in my system
Note...
java Compilation import
java .util.*;
class ArrayListDemo... in
Java 5 and later if you're using collections without type specifiers (e.g.
Advertisements
java Compilation
java program
compilation time following error is occur in my system
Note...
java Compilation import
java .util.*;
class ArrayListDemo... in
Java 5 and later if you're using collections without type specifiers (e.g.
java compilation error - Hibernate
java compilation error hi, i have made an registration page whosevalues should be inserted into database. i have used hibernate and eclipse it is working fine. but when i make a war file and deploy it using ant and then run
compilation error - Java Beginners
compilation error class s
{
public static... is the reason? Hi Friend,
In
Java there are some specific literal... not in the Hexadecimal or Octal. Here is fraction of
Java code example which will help you
Java Compilation - Java Beginners
Java Compilation How would i write a complete
java program which, using a do-while loop, reads integers from the keyboard and sums them until the sum hits or exceeds 30. Then print out the sum.
is it like this:
import
Java Compilation - Java Beginners
Java Compilation I want to write a complete
java program that catenates the file named "first" with the named "second" and produces a file named "third". If either input file "first" or "second" does not exist in the current
Java Compilation - Java Beginners
Java Compilation I want to write a
Java program that asks the user for the names of 3 files. I want the first file to be opened for reading and the other two files to be opened for writing.
I want the program to read
java compilation error - Java Beginners
java compilation error i have downloaded
java software(version 6... from where i should download
java or what to do now? Have you set the
java_home and path in your environmental variables in "My Computer
compilation problem
compilation problem struts 2.0 : i have included all 5 jars in lib folder,but its giving
compilation problem that package open symphony doesnot exist ( though i imported it) & cant recognise SUCCESS etc symbol.i think i
compilation problem
compilation problem struts 2.0 : i have included all 5 jars in lib folder,but its giving
compilation problem that package open symphony doesnot exist ( though i imported it) & cant recognise SUCCESS etc symbol.i think i
compilation fail
compilation fail package jsptube.tutorials.servletexample;
import javax.servlet.GenericServlet;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
import
compilation error
compilation error Hi my program below is not compiling,when I try to compile it i'm getting the error message "tool completed with exit code 1".The loop has to be at the end of the program can you help me.
Blockquoteimport
compilation errors
compilation errors package jsptube.tutorials.servletexample;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import
command prompt is compilation is not working
command prompt is
compilation is not working Dear
java users can anyone help me to run the program in command line prompt i tried by selecting... and the class file is also getting generated when i run the class file using
java
Hibernate Configuration
org.hibernate.SessionFactory . Various XML mapping files or
Java Annotations
compilation build...The configuration of Hibernate is handled by the instance of org.hibernate.cfg.Configuration . It symbolizes the complete mapping between
Java data types
Java
Java What is a
compilation unit
java & c
java & c why c language is called top down approach?
why
java is called bottom to top approach?
In C,
compilation stats from the very top of the program code. In
Java, on the other hand, we have user defined data
java fundamental question related to string
java fundamental question related to string public class Myclass...??);
}
}
Output?
a) the pgm will throw ClassCastException
b)
compilation fails since s==sb illegal
c)
compilation fails since s.equals(sb) illegal
d
java fundamental question
java fundamental question public class WrapTest3
{
Public static void main(String args[])
{
String s="98.6";
// insert code here
}
}
Which will cause
compilation error:
a) float f1=Float.floatValue(s);
b) float f2=new Float
java fundamental question
java fundamental question public class TestVarArgs
{
Public void display(Double i, double â?¦ j)
{
System.out.println(â??Double& var argsâ... Double & Double
c)
compilation error due to ambiguous method calls
d
php java
php java why PHP is becoming more popular than
java
PHP is more popular than
Java because of following reasons:
1)PHP web hosting...
Java for web development:
Lower barrier to entry
Dynamic typing
Simpler hello
Which is better .Net or Java?
or Ahead of Time
Compilation while
Java has Just In Time
compilation.
Java...When a developer needs to choose between
Java or .NET to develop a new..., it can also be used on other operating system.
Java on the other hand
Java Generics
replace a
suitable
java type during
compilation with the help of these parametric...
.style1 {
list-style-type: square;
}
Java Generics
The Generics...
compilation. The
main reason of using Generics code is to assures type safety