This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array" Watch "Array" New topic
Author

Array

kundana sharma
Greenhorn

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
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

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).

So...you 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: 231
    
    1

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.
 
Don't get me started about those stupid light bulbs.
 
subject: Array
 
Similar Threads
Swapping of two Strings in the form of character arrays.....
Two-dimensional array lengths????
ClassCastException while using Collections. sort(Vector,Comparator)
Writing to multiple file
ClassCastException while using Collections. sort(Vector,Comparator)