• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7630
  • Last Modified:

convert string array to long array in java.

how do i convert string array to long array in java.

this is what i have

String[] IdsArray = Ids.split(",");

I want to convert this to have an array of long values
0
anup001
Asked:
anup001
  • 2
1 Solution
 
objectsCommented:
long[] l = new long[idsArray.length);
for (int i=0; i<l.length; i++)
{
  l[i] = Long.parseLong(idsArray[i]);
}
0
 
anup001Author Commented:
When I used above i get the following error when i try to pass array l[i]

The method setNames(Long[]) in the type NameRequest is not applicable for the arguments (long[])      

Whats the difference between Long and long and how do i fix it?
0
 
objectsCommented:
it expects Long not long
Long[] l = new Long[idsArray.length);
for (int i=0; i<l.length; i++)
{
  l[i] = new Long(idsArray[i]);
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now