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
2
votes
2 answers

2D ArrayList to a normal array java

Basically, I am creating a dynamic 2d ArrayList. private ArrayList myArray; This code below is done in loop. A few random strings of the "same length" is given to store the all the characters in array. while (body) char[] temp =…
2
votes
0 answers

AttributeError: 'int' object has no attribute 'toarray'

I tried to solve this issue but the error keeps persistent. It is not a problem for English texts, but it is so for Arabic. Any idea how to solve this problem? top_n_words_lsa = get_top_n_words(10, lsa_keys, small_document_term_matrix,…
2
votes
2 answers

What is the full version of this lambda expression?

I am having considerable difficulty understanding this toArray function. Can somebody please provide the full context of this method without using the lambda arrow or a double :: colon method reference? It is more helpful that I know the full…
Strom
  • 93
  • 1
  • 10
2
votes
4 answers

ToArray() function limitation

I am using the .ToArray() method to convert my string to char array whose size i have kept char[] buffer = new char[1000000]; but when I am using the following code: using (StreamReader streamReader = new StreamReader(path1)) { buffer =…
pranjal khanduri
  • 351
  • 1
  • 3
  • 16
2
votes
1 answer

c# csvfile to array

I had a .csv file with many lines and 3 columns (separated by ';') with numbers, which I convert to double array[][] Now I've added to more columns of numbers and get an error: FormatException -> Input string was not in a correct format I can't…
Leinad
  • 41
  • 6
2
votes
1 answer

In Scala, how to use 'toArray()' to turn a stack to a array?

I use the 'toArray' api of immutable.Stack like the codes below in Scala, but it reports error. var stack1 = mutable.Stack[Long]() val array = stack1.toArray(); It reports 'Cannot resolve reference toArray with such signature' about toArray and…
ShadowSocks
  • 43
  • 1
  • 5
2
votes
0 answers

Alternative for toArray to increase perfomance in terms of time

I use newrelic to know the stats for the performance of my website and I got to know a get command to an entity is taking too much time. The segment "MongoDB ms.users toArray" is taking around 248,000 ms. Any suggestions to improve the time?
Abhinav Saini
  • 288
  • 4
  • 16
2
votes
1 answer

Convert DF into Numpy Array for calculations

I have the data in a dataframe format that I will use for linear regression calculation using user-built function. Here is the code: from sklearn.datasets import load_boston boston = load_boston() bos = pd.DataFrame(boston.data) # convert to…
Toly
  • 2,981
  • 8
  • 25
  • 35
2
votes
1 answer

Missing arguments for method toArray in trait List when converting from java ArrayList to scala Array

I have this simple code: import java.util import scala.collection.JavaConversions._ def f(x: util.List[Int]): Array[Int] = { x.toArray[Int] } It is failing on error: missing arguments for method toArray in trait List However the source code for…
mirelon
  • 4,896
  • 6
  • 40
  • 70
2
votes
1 answer

Symfony2: Call to a member function toArray() on a non-object

Hy, I've a short question about a weird error message I get on my Symfony 2 project. I've an entity class User which retrieves its roles via Doctrine. This works perfectly! But... I want let the User implement EquatableInterface, so I've added the…
andi1984
  • 676
  • 10
  • 27
2
votes
4 answers

Convert members of struct in a list to array

To process data from a log file, I read the data into a list. When I tried to convert from the list to an array for the graphing routine, I ran into trouble. For the sake of this discussion, let's say the log file contains three values* - x, y and…
Harjit Singh
  • 23
  • 1
  • 3
2
votes
5 answers

Why cant I cast Object[] to StringBuilder[] in Java?

ArrayList al = new ArrayList<>( Arrays.asList(new StringBuilder[]{ new StringBuilder("Oracle"), new StringBuilder("Java"), …
Laz London
  • 302
  • 1
  • 3
  • 11
2
votes
5 answers

ArrayList fail to convert to a String array using (String[])list.toArray(). Why?

Why the below code fail to execute though it wont detect as an error from the IDE. And it will compile fine. ArrayList a = new ArrayList(); a.add("one"); a.add("two"); a.add("three"); String [] b =…
prime
  • 14,464
  • 14
  • 99
  • 131
2
votes
3 answers

putting data from a LinkedBlockingQueue<> to an array not of type object

I am trying to do copy from a LinkedBlockingQueue to a dataStuff[] data array using .toArray() but I am getting an Exception Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [LdataStuff; at…
JohnM
  • 105
  • 10
1
vote
3 answers

C# ToArray function in .NET 2.0

In .NET 3.5 or 4.0 I can use this (just an example): var d = ("D").ToArray(); But the same doesn't work in 2.0 because there is no ToArray() method. How can I "convert" this code to .NET 2.0? I am using WinForms.
dnclem
  • 2,818
  • 15
  • 46
  • 64
1 2
3
9 10