• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array

 
kundana sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic