Lost Password?

Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-10-2008, 06:20 AM
thieflock thieflock is offline
Newbie
 
Join Date: Jun 2007
Posts: 14
Rep Power: 0
thieflock is on a distinguished road
Default Creating an array without a predefined size?

I know I need to define an array size before the variables unless I use method(dataType...arrayName), I just need someone to help me with the concept. I have a JOptionPane.showInputDialog that asks for x number of integers. I need to convert the string to integers and create a method that will take these integers and store them in an array. Please do not tell me to use ArrayList because I am basically supposed to create those same methods myself. And please do not tell me to use LinkedNodes because again I am not allowed to do this. There is no need to show me any code but if you can give me some ideas about how to do this I would be very grateful. It have been bothering me since last night.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-10-2008, 05:17 PM
keller's Avatar   
keller keller is offline
Newbie
 
Join Date: Dec 2007
Location: Iowa
Age: 31
Posts: 21
Rep Power: 3
keller is on a distinguished road
Default Re: Creating an array without a predefined size?

Do you need to create the array before you process the string? If you don't then just get the string length and use that to initialize the array.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 06:12 PM
keller's Avatar   
keller keller is offline
Newbie
 
Join Date: Dec 2007
Location: Iowa
Age: 31
Posts: 21
Rep Power: 3
keller is on a distinguished road
Default Re: Creating an array without a predefined size?

Does this help?

Code:
public class Test
{

   int[] test;
   public String in;
   
   public Test(String input)
   {
      in = input;
      int y = in.length();
      test = new int[y];
      for (int i = 0; i < in.length(); i++)
      {
         test[i] = Integer.parseInt(String.valueOf(in.charAt(i)));
      }
      for (int x=0; x<test.length; x++)
      {
         System.out.println(test[x]);  
      }
   }
   
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Usage of array structures to increment letter instances of text Yuriy M C and C++ 2 09-13-2007 10:49 AM
Othello program!! 24 hours left! siren C and C++ 1 06-14-2007 11:18 AM
Python 2D array question annannienann Python 3 04-23-2007 04:36 PM
Dyanmically setting the size of an array hoser2001 C and C++ 3 10-17-2006 04:56 AM
Directory Size John PHP Forum 5 08-06-2006 01:02 PM


All times are GMT -5. The time now is 11:43 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
LogicKills ........ 20.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads