File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array" Watch "Array" New topic


kundana sharma

Joined: Sep 09, 2012
Posts: 10
I am solving this problem:A user inputs a string consisting only alphabets and numbers (qqw123sfw33434).Now my job is to print an alphabet and a number like (q1q2w3s3f3w434) .I am able to extract both the both the Strings and integers into separate arrays.Now I need a logic to print one element of the array followed by another:
My code:

I know I am getting null pointer exception
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

nobody here is going to give it to you...we'll help you figure it out.

And the first step to do that is to think about it NOT in java/programming terms, but in English (or some other natural language). have two lists: a list of letters, and a list of numbers.

Describe the steps you (or better, a 10 year old child) should follow to speak all the values out loud in the order you want.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Joel Christophel
Ranch Hand

Joined: Apr 20, 2011
Posts: 249

Before you start the step you're attempting, you need to back up and change some things. You're not going to find your two arrays in their current states to be very useful/helpful in the solving of this problem. For example, tokensStrings holds the following Strings: "qqw", " ", " ", "sfw". To make your job a lot simpler, you first need to find a way to store each letter in its own index: "q", "q", "w", "s", "f", "w". Do the same with tokensInts. If you're still having problems after you've done that, I'll be glad to help you further.
I agree. Here's the link:
subject: Array
jQuery in Action, 3rd edition