Throwing string exception with integers
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Throwing string exception with integers

  1. #1
    Join Date
    Feb 2012
    Posts
    17

    Throwing string exception with integers

    Hello, Im looking for an example of how to throw an exception for an input string that;

    rejects characters in the alphabet such as "abc..."
    and only accepts numbers in the form of "1 2 3.."

    Im fairly new to java and Im just looking for a solid example of this code.

    -Nelson

  2. #2
    Join Date
    Nov 2006
    Location
    Barcelona - Catalonia
    Posts
    362

    Re: Throwing string exception with integers

    This seems homework. Please, read this

    We are here to help, not to do your homework. If we give you the answer, you'll never learn. Tell us what you tried, what you don't understand or where you are stuck, and we'll be very glad to help you.

    Regards,

    Albert.
    Last edited by AlbertGM; July 19th, 2012 at 04:21 AM.
    Please, correct me. I'm just learning.... and sorry for my english :-)

  3. #3
    Join Date
    Jan 2011
    Posts
    24

    Re: Throwing string exception with integers

    I guess you want to filter numeric string with alphabetic String. on homework front , mods are correct but I am giving you some hint which is applicable in general.

    1) There are methods in Java API which converts String to number like Integer.parseInt(String) which can throw NumberFormatException is String can not be converted into number. there are couple of more ways to do this you can also see this link http://javarevisited.blogspot.sg/201...to-string.html.

    2) For getting input from user you can use java.util.Scanner class.

    try working with these information and post here if you face any issue, that would improve your learning without being stuck.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center