Skip to main content

All Questions

Tagged with
0 votes
4 answers
1k views

What prevents Java from having immutable primitive arrays?

Java never had immutable primitive arrays. However Java does have an immutable List or Map or other collection classes and of course final primitive fields and variables. In Java if you try to make an ...
CPlus's user avatar
  • 1,199
0 votes
0 answers
139 views

Best choice for a holding large number of objects in java

I have a set of array, containing a large number of objects (products), which has lately grown so large, searching in it takes about a minute, which is considered too long, since one search is ...
kry's user avatar
  • 101
-2 votes
2 answers
1k views

Comparing and replacing values in an array [closed]

I am currently working on a program that replaces the value in an array if the value next to it is the same as the current value. So If the array is [0,0,0,1,0,1,0], when the program runs it'll turn ...
Y3LLZ's user avatar
  • 13
-2 votes
1 answer
3k views

Generate large Excel files and response from API

I need to generate a large Excel file (something around 50 megs) and send response to another API which will provide it to the front end for a download option. My question is if it will be better to ...
JackTheKnife's user avatar
-2 votes
1 answer
2k views

C# is fantastic, if only List 'd respect Remove&Return [closed]

In the domain of system-modeling (e, systemVerilog, matlab, phyton), lists are obsoleting arrays, stacks and queues(*) altogether. Other domains that use python, perl and ruby have that same mindset, ...
jsonphy's user avatar
  • 57
4 votes
2 answers
6k views

How exactly indexing works in arrays?

I only know that index is faster but don't know why is it faster. Suppose I have an array int[] a = {2,3,6,7}. Then I will try to find the element at a[3] and the speed of this will be O(1). Why? How ...
Asif Mushtaq's user avatar
2 votes
3 answers
3k views

Return array pointers vs. populating an array inserted as a parameter?

Which is better? I noticed the latter is used in a lot of C code. People will typically malloc an array, and then pass that as a parameter to a function, which will then populate it. Whereas in Java, ...
user3724404's user avatar
-4 votes
2 answers
4k views

How to create a method that takes array list as argument?

To create a method that takes an array as an argument, you would do this: public static void printAges(int[] age) { // prints ages to screen for (int x = 0; x < age.length; x++) { ...
Krish's user avatar
  • 1
1 vote
2 answers
6k views

Example of problem caused by casting Object[] to E[]

I've heard here and there that arrays contain runtime data about their type, making you unable to instantiate an E[] (E being a generic type parameter, for example in a class Foo<E>), and that ...
Phoenix's user avatar
  • 758
3 votes
5 answers
816 views

Why isn't byte | bit the only built in data type?

All languages I have seen so far have multiple builtin data types (int, double, float, char, long...). But if we look closely, they are just arbitrary arrays of bits, the only difference between them ...
Ford O.'s user avatar
  • 223
0 votes
1 answer
1k views

Reference variable concept (Java)

I'm working my way (slowly, but surely) through a book: Introduction to Java Programming, 10th edition, Comprehensive, by J. Liang (ISBN10: 0133761312) It explains the idea of a reference variable ...
silenceislife's user avatar
1 vote
1 answer
194 views

Removing constraints of Java array

Java arrays only allow subscripts to range between 0 and N-1 for an array of size N. The class below aims to remove that constraint by allowing the class user to specify the valid subscripts ...
M-R's user avatar
  • 237
-6 votes
2 answers
2k views

ArrayList Dynamic remove and add for socker client [closed]

I have one ArrayList in Java and a save the socket and one unique id. When someone client is add in the ArrayList, the unique id i have is NOT the same with position in ArrayList. When someone ...
pioupiou's user avatar
  • 101
-1 votes
1 answer
1k views

What is the proper or recommended way to save String[]'s, Array's, ArrayList's and int[]'s to Android?

I've looked up this question many many times but keep seeing different answers, what is the BEST way to save array's? It seems ludicrously infantile that there is no standard or easy way to save ...
420blazeit's user avatar
3 votes
4 answers
9k views

Readability & Performance: Is it better to allow the Java garbage collector to clear a datastructure?

I work with large HashMap's and ArrayLists. When not needing them to be in memory any longer, I use myArray.clear(); to free up the memory. When my colleague saw that line, he changed it to myArray ...
Nav's user avatar
  • 1,191

15 30 50 per page