convert string array to long array in java.

Posted on 2007-10-01
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
Question by:anup001
    LVL 92

    Expert Comment

    long[] l = new long[idsArray.length);
    for (int i=0; i<l.length; i++)
      l[i] = Long.parseLong(idsArray[i]);

    Author Comment

    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?
    LVL 92

    Accepted Solution

    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]);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now