An unchecked or unsafe operation is used in Java

Source: Internet
Author: User

1. javac-xlint:unchecked Mymath.java Check for unsafe operations

/***************************************************/

MYMATH.JAVA:29: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("1");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:30: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("2");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:31: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("3");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:32: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("4");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:33: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("5");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:34: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("6");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:35: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add ("7");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:37: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

Array.add (array);

^

where e is the type variable:

E extends the object declared in class ArrayList

mymath.java:68: Warning: [unchecked] a call to set (Int,e) that is a member of the original type ArrayList has not been checked

Array.set (3, "hahah");

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:72: Warning: [Unchecked] call to add (Int,e) as a member of the original type ArrayList not checked

Array.add (5, "5a");

^

where e is the type variable:

E extends the object declared in class ArrayList

mymath.java:87: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

List.add ("1");

^

where e is the type variable:

E extends the object declared in class ArrayList

mymath.java:88: Warning: [unchecked] a call to add (E) that is a member of the original type ArrayList is not checked

List.add ("2");

^

where e is the type variable:

E extends the object declared in class ArrayList

mymath.java:91: Warning: [unchecked] call to AddAll (int,collection<? extends E>) as a member of the original type ArrayList not checked

Array.addall (1,list);

^

where e is the type variable:

E extends the object declared in class ArrayList

MYMATH.JAVA:99: Warning: [unchecked] a call to Retainall (collection<?>) that is a member of the original type ArrayList has not been checked

Array.retainall (list);

^

14 warnings

Bogon:javacode zyyt$ Javac Mymath.java

Mymath.java:7: Error: Requires class, interface, or enum

@SuppressWarnings ("unchecked"); the solution given

/***************************************************/

That's all you have to solve.

class preceded by @suppresswarnings ("unchecked")

@SuppressWarnings ("Unchecked")

public class mymath{

}

An unchecked or unsafe operation is used in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.