aspose file tools*
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
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: 11499
    
  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: 241
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array