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

  • Home
  • SEARCH
  • 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 7777085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:02:52+00:00 2026-06-01T18:02:52+00:00

How would be a c# .net generic list in java? somthing like that: public

  • 0

How would be a c# .net generic list in java?

somthing like that:

public class ClientList : List<Client> { }

the answer from Nikil was perfect, I just want to add to whoever wants to create a class from the List:

public class ClientList extends ArrayList<Client>
  • 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-06-01T18:02:54+00:00Added an answer on June 1, 2026 at 6:02 pm

    Java’s List interface (java.util.List) can be generified. In other words, instances of List can be given a type, so only instances of that type can be inserted and read from that List. Here is an example:

    List<String> list = new ArrayList<String>();
    

    This list is now targeted at only String instances, meaning only String instances can be put into this list. If you try to put something else into this List, the compiler will complain.

    The generic type checks only exists at compile time. At runtime it is possible to tweak your code so that a String List has other objects that String’s inserted. This is a bad idea, though.

    Accessing a Generic List

    You can get and insert the elements of a generic List like this:

    List<String> list = new ArrayList<String>();
    
    String string1 = "a string";
    list.add(string1);
    
    String string2 = list.get(0);
    

    Notice how it is not necessary to cast the object obtained from the List.get() method call, as is normally necessary. The compiler knows that this List can only contain String instances, so casts are not necessary.

    Iterating a Generic List

    You can iterate a generic List using an iterator, like this:

    List<String> list = new ArrayList<String>();
    
    Iterator<String> iterator = list.iterator();
    
    while(iterator.hasNext()){
        String aString = iterator.next();
    }
    

    Notice how it is not necessary to cast the object returned from the iterator.next() next call. Because the List is generified (has a type), the compiler knows that it contains String instances. Therefore it is not necessary to cast the objects obtained from it, even if it comes from its Iterator.

    You can also use the new for-loop, like this:

    List<String> list = new ArrayList<String>();
    
    for(String aString : list) {
        System.out.println(aString);
    }
    

    Notice how a String variable is declared inside the parantheses of the for-loop. For each iteration (each element in the List) this variable contains the current element (current String).

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

Sidebar

Related Questions

I have a C# class derived from a generic list public class CostCodes :
I would like to create a console program in VB.net that would allow parameters.
I've written an ASP.NET web service that I would like a .NET 3.x application
In .NET land I would normally query the database and populate a generic List
I have anywhere from 5 to 10 generic list in an ASP.NET VB.NET web
Is there a library of generic collection algorithms for .NET? I would like to
Winforms .net 3.5 app. In my app I have a generic class that looks
I have few methods that returns different Generic Lists. Exists in .net any class
in vb.net i would like to change the hue and saturation and darkness of
in vb.net i would like to draw a regular line on a form. is

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.