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: Java Error.....Help needed

  1. #1
    Junior Member
    Join Date
    Jul 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java Error.....Help needed

    This is a program to input a sentence and print the words that start with a vowel.......There is no syntax error but on executing and typing the sentence and pressing enter,I get a error saying :

    java.lang.StringIndexOutOfBoundsException: String index out of range: 0
    at java.lang.String.charAt(String.java:658)
    at sentence.main(sentence.java:22)




    ----------------------------------------------------
    ----------------------------------------------------
    import java.util.*;
    public class sentence
    {
    public static void main()
    {
    Scanner in=new Scanner(System.in);
    System.out.println("Enter a sentence");
    String s=in.nextLine();
    String c="";
    String d="";
    int l=s.length();
    for(int i=0 ; i<=l ; i++)
    {
    char b=s.charAt(i);
    if(b!=' ')
    {
    c=c+b;
    }
    else
    {
    c=d;
    }
    char e=d.charAt(0);
    if(e=='A' || e=='E' || e=='I' || e=='O' || e=='U' || e=='a' || e=='e' || e=='i' || e=='o' || e=='u' )
    {
    System.out.println(d);
    }
    c="";
    }
    }
    }
    Last edited by Ashtagger; July 23rd, 2014 at 06:57 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: IMMEDIATE HELP NEEDED ASAP!

    Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

    Please post your code correctly per the above link.

    Please give your threads appropriate titles, and shouting is not necessary. I believe you can edit your post, including the title.

    An urgent need on your part does not typically translate to an urgent requirement to help you, sometimes the opposite effect is achieved.

Similar Threads

  1. Grails Developer Needed - URGENTLY NEEDED *WORK FROM HOME*
    By IngeniumR in forum Paid Java Projects
    Replies: 0
    Last Post: February 5th, 2013, 07:19 AM
  2. NEED HELP ASAP PLEASE
    By jaisan72980 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 13th, 2011, 11:29 AM
  3. help needed ASAP
    By minaa07 in forum AWT / Java Swing
    Replies: 1
    Last Post: October 4th, 2011, 09:08 AM
  4. NEED HELP ASAP PLEASE!!!
    By mbm4ever in forum What's Wrong With My Code?
    Replies: 8
    Last Post: August 12th, 2010, 07:01 PM
  5. Replies: 0
    Last Post: July 19th, 2010, 04:30 PM