This question already has answers here:
Java: Difference Between a collection and 'Data Structure' [closed]
(3 answers)
Closed 7 years ago.
I want to learn data structures and algorithms in java but I'm confused if collections are data structures or if there is something else . A brief explanation on data structures would help.
Thanks
Collections are data structures! Data structures are just advanced ways to hold simple data (simple being integers, strings etc.) data structures being things like Arrays, Collections.
Related
This question already has answers here:
Is there a common Java utility to break a list into batches?
(21 answers)
Closed 6 years ago.
I have a list that may be over 1000 strings, however I do not know how many exactly.
What is the best way to split this list into smaller lists without loosing any members of the list?
For example If I have a list of 1323 members, how can I best split it into 3 almost evenly sized lists?
I have seen the Guava and Commons way of splitting lists by the partition function, but that function will split the list into given size of chunks and not given number of groups (sub-lists).
Guava has a function Lists.partition which will do this for you
Usage:
Lists.partition(mylist, mylist.size()/3);
This question already has answers here:
Deserializing a java serialized file in C#
(3 answers)
Closed 6 years ago.
I have a very old Java application that I am rewriting in .net, I can't change the Java code or the old files in any way.
They have created and stored 10,000+ files that match the format described in this article, a bunch of serialized Java objects.
Question
How can I parse these Java objects in c#?
Is this even possible?
In the end, if I can read in and serialize the data, I can store it in a more universal format. When I try to deserialize the file I reach an exception, usually telling me the binary format is not valid.
A similar question has been asked here.
You have a few options. One is to write a C# class capable of reading objects in Java's serialized format (the one you linked) but this is likely very time consuming. Using C#'s native deserialization algorithm won't work because the format is different (as you've encountered).
An easier alternative is to read the objects from the files using a Java program, and save them as a more universal format such as JSON. (As recommended in an answer to another question here)
This question already has answers here:
Why not always use ArrayLists in Java, instead of plain ol' arrays?
(5 answers)
Closed 8 years ago.
I've played around with arrays and arrayLists. Sorting is a breeze with arrayLists but I can not say the same with arrays. You have to make a for loop and filter the results and it's a pain. As far as I can see arrayList are just a better version of arrays. So why use arrays? Is there something they can do better.
Sorting with arrays and ArrayLists is equally easy: there are already implementations for sorting both of them:
Sorting ArrayLists
Sorting Arrays
The reasons for using one of the other are more of memory concerns, speed concerns or because your problems is better suited to be solved with one or the other.
This question already has answers here:
Bidirectional multi-valued map in Java
(6 answers)
Closed 9 years ago.
Is there an implementation of the following data-structure already implemented in Java:
Say I want the set for '2' ('A', 'C', 'D') but I also want the set for 'A' ('1', '2')
You have no such data structure in the Java Collections Framework.
I suggest you the guava library you may find something useful there.
Note that what you have here is essentially a undirected graph so keep an eye out for graph libraries (for example JGraphT), or write your own.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to serialize an object into a string
i want to store an object into relational database whereas that database only takes ASCII or string format.so how can i store my object to that database so that i can get back without losing persistence of that object.
I am not a java developer but I use json in such circumstances. This is a link I found on stackoverflow. Might be helpful to you. https://stackoverflow.com/questions/338586/a-better-java-json-library