Questions tagged [generic-collections]

A collection that supports generic typing of its elements

Since java 1.5 (released in 2004), the JDK java.util.Collection interface is generic (typed).

Unless you're using an ancient version of java, the word "generic" in "generic collections" is redundant.

390 questions
-2
votes
1 answer

How to iterate through a list of unknown type in JAVA

I have 2 lists of Generic type. List1 of type Generic_Class1 List2 of type Generic_Class2 I want to iterate through above lists in single for each loop. like, for(Generic_Class loop_variable: List1/List2){ } Is it possible to do in JAVA?
-2
votes
2 answers

what is the difference between Stack st = new Stack() and Stack names = new Stack(); in c#

What is the main difference both of them and which one is better. can we add mix of data in both or not. what is the difference between Stack st = new Stack() and Stack names = new Stack();
-2
votes
1 answer

C# Collections vs Arrays: Longest Increasing Subsequence Benefits

What's the performance penalty that I can expect if I'm using Lists over Arrays to solve the Longest Increasing Subsequence? Will the dynamic nature of Lists improve average performance because we're not dealing with sizes we won't actually…
devadviser
  • 120
  • 1
  • 12
-2
votes
1 answer

"Enumeration yielded no results" when there is clearly a result

I'm troubleshooting an old application and having a hard time understanding why a variable isn't entering a foreach loop. My problem is that I have very limited experience dealing with Generics/Collections/LINQ. Please excuse me if this is an…
comfortablyNumb
  • 195
  • 1
  • 17
-2
votes
1 answer

C# Console writeline print out generics list collection

I need to print out the content of this Generic List with console writeline if is possible .Thanks in advance for your help. This question is about this specific piece of code ,I did many search but without luck. code : using System; using…
Mercury77
  • 45
  • 1
  • 10
-2
votes
2 answers

Generic Collections C#

I have implemented a generic custom collection class which only takes a Person type object. While providing support for the Enumerator to iterate through the collection it shows an error Cannot apply indexing with [] to an expression of type…
Deepanshu
  • 25
  • 7
-2
votes
1 answer

Best Linq Syntax for To Create List for JQuery Autocomplete

I'm trying to create a list of strings (on a controller method for use as JSON that is consumed by a JQuery Autocomplete on the client). Is there a way to reduce these six or seven lines to two lines? In other words I want the first line to create…
Frank Cannon
  • 1,643
  • 2
  • 18
  • 29
-2
votes
2 answers

Move Selected elements of a Map up or down

I am trying to modify a list of elements in a Map by moving the selected items up or down. My idea is to remember the elements next to selected items. Because the elements are in a map, I find it much difficult to do it though I use a LinkedHashMap…
-3
votes
4 answers

Is there a better way to write a C# function that accepts multiple types?

Some context: I'd like to write a class where the main method for adding things to a collection is through a method (or methods) that are named Add (or something like that). And so the signature that seems best is params object[]. Internally, this…
lucidquiet
  • 6,124
  • 7
  • 51
  • 88
-3
votes
3 answers

City instead of id seems on dropdownlist value

I have a problem when load dropdownlist, city instead of id seems on dropdownlist value. What is the problem? #region CITIES public List loadCities() { using (SqlConnection conn = new SqlConnection(DataBase.Conn)) { …
-3
votes
1 answer

Replace foreach with java8

How can I convert this code as per java8 having an inner list inside a parent list and do filtering? for(A aobj: branchList) { for(C cobj : aobj.getCList()) { if(!enteredBranchId.equals(cobj.getId()) …
Daniel Atlas
  • 1
  • 2
  • 5
-4
votes
2 answers

Cannot pass Object which extend of a abstract one into a Method with the abstract Object as Parameter

Here's the code of the method: public void setupList(ArrayList list) { //Here´s the Code stuff. This Method is in the Class: AlphabeticList } And I tried to call this method with: setUpList(new ArrayList); The…
-4
votes
1 answer

Use List of custom Business Objects as ComboBox datasource

I have class like this: class MyClass { public string FirstProperty { get; set; } public int SecondProperty { get; set; } public MyClass(int i, string s) { FirstProperty = s; SecondProperty = i; } } and a Winform…
ArtK
  • 1,157
  • 5
  • 17
  • 31
-5
votes
3 answers

what is the difference between arraylist with and without <> operator

I giving a mock test on SCJP. I encounter two different question having the statements as ArrayList arr = new ArrayList(); and ArrayList arr = new ArrayList(); 1) What is the differnce between these two? My Analysis=> first can…
dead programmer
  • 4,223
  • 9
  • 46
  • 77
-6
votes
1 answer

What's more efficient in .Any and .Count in C# (Extension methods)

public void MethodName(ObservableCollection dataCollection) { if (dataCollection != null) { IsChecked = dataCollection.Any(o => o.DataCollectionID.Equals(30)); IsChecked =…
Rosh
  • 55
  • 6
1 2 3
25
26