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

136 questions
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
  • 89
  • 1
  • 8
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
  • 321
  • 3
  • 15
2
votes
1 answer

C# - strange behaviour with ToList() and ToArray()

I noticed some strange behavior when using a combination of ToList() and ToArray() in C# (using the .NET 4.5.2 famework). Given the following test program: int[] array = { 5, 1, -10, 667, 4 }; SorteerBib.SelectionSort(array,…
PjM
  • 33
  • 2
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
  • 258
  • 3
  • 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
  • 1,725
  • 6
  • 19
  • 30
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,498
  • 6
  • 37
  • 64
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
  • 656
  • 8
  • 26
2
votes
1 answer

toArray() vs. toArray(new Object[0])

I have an ArrayList called listtable. For some reason Clause[] whatever = listtable.toArray() gives an incompatible types error but Clause[] whatever = listtable.toArray(new Clause[0]) works just fine. Why is this so? What is the difference…
Elliot Gorokhovsky
  • 3,034
  • 2
  • 28
  • 47
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
  • 247
  • 3
  • 9
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
  • 11,246
  • 11
  • 75
  • 112
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.
rayanisran
  • 2,536
  • 12
  • 43
  • 59
1 2
3
9 10