Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:48:41+00:00 2026-05-28T14:48:41+00:00

when cleaning & building my project in NetBeans there’s a warning that says unsafe

  • 0

when cleaning & building my project in NetBeans there’s a warning that says “unsafe operations” so I use -Xlint:unchecked to see those operations but I cannot understand what am I doing wrong. These are the warnings and then my code thanks !

UploadBean.java:40: warning: [unchecked] unchecked conversion
    private final List fileList = Collections.synchronizedList(new ArrayList());
  required: List<T>
  found:    ArrayList
  where T is a type-variable:
    T extends Object declared in method <T>synchronizedList(List<T>)


UploadBean.java:40: warning: [unchecked] unchecked method invocation: method synchronizedList in class Collections is applied to given types
    private final List fileList = Collections.synchronizedList(new ArrayList());
  required: List<T>
  found: ArrayList
  where T is a type-variable:
    T extends Object declared in method <T>synchronizedList(List<T>)


UploadBean.java:97: warning: [unchecked] unchecked call to add(E) as a member of the raw type List
                    fileList.add(fd);
  where E is a type-variable:
    E extends Object declared in interface List
3 warnings

CODE

 //This is line 40    
 private final List fileList = Collections.synchronizedList(new ArrayList());

 //This is line 88
 public void doUpload(FileEntryEvent e) {
        FileEntry file = (FileEntry) e.getSource();
        FileEntryResults result = file.getResults();
        for (FileInfo fileInfo : result.getFiles()) {
            if (fileInfo.isSaved()) {
                FileDescription fd =
                        new FileDescription(
                        (FileInfo) fileInfo.clone(), getIdCounter());
                synchronized (fileList) {
                    fileList.add(fd); //This is line 97
                }
            }
        }
    }

cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:48:41+00:00Added an answer on May 28, 2026 at 2:48 pm

    You need to learn about Java Generics. The old 1.4 style will still compile, but it will do so with warnings (considered errors by some).

    Since the classes you are using expect Generic Type parameters, they need to be specified to the compiler, like so:

     //This is line 40    
     private final List<FileDescription> fileList = Collections.synchronizedList(new ArrayList<FileDescription>());
    
     //This is line 88
     public void doUpload(FileEntryEvent e) {
            FileEntry file = (FileEntry) e.getSource();
            FileEntryResults result = file.getResults();
            for (FileInfo fileInfo : result.getFiles()) {
                if (fileInfo.isSaved()) {
                    FileDescription fd =
                            new FileDescription(
                            (FileInfo) fileInfo.clone(), getIdCounter());
                    synchronized (fileList) {
                        fileList.add(fd); //This is line 97
                    }
                }
            }
        }
    

    Note that with generics, some types of casting is no longer necessary. For example, fileList.get(0) will return a FileDescription in the above example, without the need to do an explicit cast.

    The generics parameter indicates that whatever is stored within the fileList must be “at least” a FileDescription. The compiler checks that it is impossible to place non-FileDescription items in the list, and the output code actually doesn’t do any run-time checks. Thus generics actually doesn’t suffer performance hits like similar techniques in other languages, however the “type erasure” preformed by the compiler makes certain techinques like Run Time Type Analysis of a Generic parameter impossible.

    Try them out, you’ll like them.

    If this code was written prior to the release of Generics, you might want to compile it with backwards compatibility flags (-source 1.4 -target 1.4).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an easier way of cleaning up a database that has a ton
I am working on cleaning up a mess that another programmer started. The created
Are there non-static equivalents to MSTest's [ClassCleanup] & [ClassInitialize]? I am using MSTest for
Lately, I've been cleaning up some some C code that runs on an ARM7
In short: is there some way I can modify a class definition such that
There's a lot of scholarly work on HTML content extraction, e.g., Gupta & Kaiser
I am trying to format xml entries I have so that I can use
This is a legacy query that I am cleaning up and I am getting
While cleaning some code today written by someone else, I changed the access modifier
I'm cleaning up CSS from a previous designer. The file is messy. One example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.