That's a pleasureJeton Shabani wrote:Thank you . . . .
But you still have a vey long method. Why are you passing the args array to run()?I have now implemented my code no longer on the main . . .
Who is teaching you?
. . . one of my first exercises in Java . . .
The ideal would be a PhoneNumber class. You can create GemanPhoneNumber and USPhoneNumber subtypes. You could try String, but as you will see here, that is not what Strings are designed for.. . . i only don't understand what type to use if i don't use long.
But you still have a vey long method. Why are you passing the args array to run()?
Who is teaching you?
Why did you use an index out of bounds exception? It is usually bad to throw an exception and catch it in the same place.
Campbell Ritchie wrote:
Phone numbers are not numbers; use the definition of a number as something you do arithmetic with. Don't use a long to return phone numbers, least of all when phone numbers often start with 0.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Tim Holloway wrote:When parsing phone numbers, I recommend simply removing all "+", "(", ")", " ", "-" and "." from the text to normalise the format. Those are simply readability characters and you won't find them on a standard phone dial/keypad.
I don't have a '+' on my phone (US).Stephan van Hulst wrote:
Tim Holloway wrote:When parsing phone numbers, I recommend simply removing all "+", "(", ")", " ", "-" and "." from the text to normalise the format. Those are simply readability characters and you won't find them on a standard phone dial/keypad.
Be careful. Most of the characters you mentioned are just there for formatting, but '+' most definitely is not.
Stephan van Hulst wrote:Be careful. Most of the characters you mentioned are just there for formatting, but '+' most definitely is not.
Tim Holloway wrote:DE is, I think +44
Nor have I, but Ron has explained what the + means.Carey Brown wrote:. . . I don't have a '+' on my phone (US).
That probably isn't what they mean by error handling. It probably means to provide some response if an incorrectly‑formatted number is supplied. That may entail throwing an exception.Jeton Shabani wrote:. . . one of the exercises was: -Provide simple error handling . . .
That probably isn't what they mean by error handling. It probably means to provide some response if an incorrectly‑formatted number is supplied. That may entail throwing an exception.
I am not at all convinced that anybody can learn programming from a book. And I am not convinced that most online tutorials are any good.
Which OCA exam?Jeton Shabani wrote:. . . they asked me to pass an exam (OCA) that I'm discovering now . . .
Carey Brown wrote:I don't have a '+' on my phone (US).
Which OCA exam?
Good grief! Without proper training, you will find a cert exam very difficult. I am not at all happy to hear about your situation
Both good choices You know, one of the authors of HFJ (=Kathy Sierra) set up this website originally. We occasionally set Bert Bates and Scott Selikoff here, and Jeanne Boyarsky is active on this site, too.Jeton Shabani wrote:. . . Head First Java then OCA Study guide by Boyarsky and Selikoff . . .
I had a good six months as part of an MSc course, then I discovered how much more I could learn from people on this site. . . proper training ?
Ron McLeod wrote:In most places in the world, a prefix of 00 indicates that the remaining digits follow are an international numbering plan (same as the + with E.164), and prefix of 0 indicates that the remaining digits follows a national numbering plan (usually an area/city code plus the local number). Without either prefix, the digits follows a local or network-specific numbering plan.
In North America however, we use 011 as the prefix for international and 1 for national.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.