Questions tagged [toarray]

toarray, to convert from arraylist to array this method can be used. Being language specific for e.g. in Java its its available with ArrayList and in C# its used with List. Use this tag for toarray related questions.

toArray() Returns an array containing all of the elements in this list in the correct order.

Resource

147 questions
0
votes
2 answers

LinkedList toArray causes crash

Everytime I tried to run these code the program crashed then I tried to get an Array of Objects from my LinkedList. Product[] arr = (Product[])produktliste.toArray(); causes the crash This is the source of the MainActivity: package…
Dominik
  • 15
  • 2
0
votes
2 answers

Java arraylist to array, array to string error

I have to read data from text.txt file, but I have strange error, my output is: [Ljava.lang.String;@5f0a94c5. The contents of text.txt file: test::test.1::test.2 test2::test2.1::test2.2 test3::test3.1::test3.2 The code: import…
trusteduser
  • 29
  • 1
  • 4
0
votes
1 answer

Scala: mutability of indexed sequences and what happens when converting to mutable and back

I have run into this scenario several times recently: a class has an immutable (indexed?) sequence member a factory member method creates a new instance with the sequence somewhat modified What's an efficient way to do this? class A( xs:…
StokedOver9k
  • 129
  • 1
  • 9
0
votes
6 answers

Collection.toArray() method, detail about it

Why would not it work? List lista = new ArrayList<>(); lista.add("Lol"); lista.add("ball"); String [] array = (String[])lista.toArray(); It throws a RunTimeException (ClassCastException), I am aware that there is…
Rollerball
  • 12,618
  • 23
  • 92
  • 161
0
votes
2 answers

Java ConcurrentSkipListMap ketset to array

I'm trying to use the following line to get an array of the keys from the ConcurrentSkipListMap : myArray=(String[])myMap.keySet().toArray(new String[myMap.size()]); But it didn't work, all the items in the result array are the same, why ?
Frank
  • 30,590
  • 58
  • 161
  • 244
0
votes
3 answers

T[] toArray(T[] a) implementation

I am creating a SortedList class that implements List. If I understand correctly, the method toArray(T[] a) takes an array of objects as a parameter and returns a sorted array of these objects. In the java documentation we can read that if the…
jpl
  • 105
  • 2
  • 11
0
votes
1 answer

How does zend framework paginator work ?

I`m using zend framework and its paginator to get an array in to pages. every thing work well but I have a question about the way paginator works. First this is my code sample : $arr=array( 'parviz','neda','yazdgerd','hooshang' …
Abadis
  • 2,671
  • 5
  • 28
  • 42
0
votes
1 answer

Moving single member of an Object in List into an array for usew in a calculation

I have a List of objects(Appliance as String and KwHHr as Double), applianceListReturn , in Visual Basic 2010. Each object has two members. I would like to take one member(KwHHr) of the same type from each object and make an array out of those…
0
votes
1 answer

Fatal error when I am using toArray() in zend framework

I need help to remove fatal error of toArray() in zend framework. Fatal error: Call to a member function toArray() on a non-object I am using following code in my controller $obj = new Admin_Model_UserMapper(); $where = array('id =…
user1414979
  • 92
  • 4
  • 11
0
votes
1 answer

Java Sorted Set of Maps converted to an array

I have these two data structures: public TreeMap tableFrequency; public SortedSet> sortedTable; sortedTable holds the same information as tableFrequency but it is sorted descendingly by…
CodeKingPlusPlus
  • 15,383
  • 51
  • 135
  • 216
-1
votes
1 answer

Viewing the elements of a set by set.toArray()

Is there a way to view the elements of a set by doing something like set.toArray()[i] (i being an integer)?
Ada
  • 21
  • 3
-1
votes
1 answer

Convert CustomList to String/Array

I have a CustomList which does everything as needed until I encountered that code like String.join(" ", list) or list.toArray(String[]::new) doesn't work with my CustomList but works with ArrayList. What am I doing wrong? CustomList adds and removes…
Judita
  • 119
  • 1
  • 2
  • 8
-1
votes
1 answer

How to convert toArray result to a CompletableFuture[] type?

I looked through dozens of answers, but most they do is advice string::new or similar tricks. In my case the type I want to convert is CompletableFuture. Here is this POJO: class ARObject { CompletableFuture texture; void…
Csaba Toth
  • 10,021
  • 5
  • 75
  • 121
-1
votes
1 answer

How can I fix the toArray method in the end?

So earlier I asked a question on how to use boolean values to access the different end of my stack. So I fixed this :) Were I am stuck now is at the end; I dont know how to implement the toArray method from the interface...ant comments or hints on…
Muriel
  • 27
  • 6
-1
votes
1 answer

Convert Map to Array Java

public Map> buildTestcases(ArrayList list){ Map> map = new LinkedHashMap>(); for(Tuple4 element: list){ String[] token = element.c.split("\\s"); …
Hendrik
  • 310
  • 6
  • 19
1 2 3
9
10