[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

convert string array to long array in java.

Posted on 2007-10-01
3
Medium Priority
?
7,611 Views
Last Modified: 2013-11-24
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
Comment
Question by:anup001
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
ID: 19994866
long[] l = new long[idsArray.length);
for (int i=0; i<l.length; i++)
{
  l[i] = Long.parseLong(idsArray[i]);
}
0
 

Author Comment

by:anup001
ID: 20010482
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
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 20010956
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month20 days, 6 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question