Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Convert string to int?

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Convert string to int?

    Okay this seems really simple, but I cant find a way around it!

    I want to input using the command line a string in the form of "10-23-2001", and then split that and put the values in 3 different integers so I can pass it through another method/function. This is what I got:

    PHP Code:
    public static void main(String dateStringInput){
            
            
    String[] dateString dateStringInput.split("-");
            
            
    int dayInput dateString[0];

    If i just output dateString[0], it does come up with the right number, but converting it to an integer seems to give me an incompatible type error. Any way around this?

    And btw, I NEED the input as a string because of a requirement.

    Hope someone could shed some light on this.

    Thanks!


    EDIT:

    Sorry guys, I worked it out (found a topic for it on here) .... Any way to delete this?
    Last edited by connex; December 9th, 2009 at 04:48 AM.


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Convert string to int?

    Please have a look at the bottom of the page where you have a list of similar threads.

    // Json

Similar Threads

  1. Conversion of string into integer in Java
    By JavaPF in forum Java Programming Tutorials
    Replies: 17
    Last Post: January 23rd, 2010, 09:33 AM
  2. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM
  3. Convert CHAR to STRING
    By fh84 in forum What's Wrong With My Code?
    Replies: 11
    Last Post: October 29th, 2009, 09:21 PM
  4. Convert Maps of String to Map of Maps
    By abhay8nitt in forum Collections and Generics
    Replies: 1
    Last Post: October 27th, 2009, 07:27 AM
  5. convert GSM to PCM (wav)
    By cilang in forum Java Theory & Questions
    Replies: 4
    Last Post: August 7th, 2009, 03:46 AM