473,385 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

i need help with arranging Arrays..

7
well..i'm trying to make a code arrange my String[] arrays into something like this..don't know how to do it..hahah..

my Array size is actually 6 but i'm only using 5..don't know why..hahaha..


Before:
data[0] = "hello"
data[1] = " ";
data[2] = "hey";
data[3] = "weeeee";
data[4] = " ";

After:
data[0] = "hello";
data[1] = "hey";
data[2] = "weeeee";
data[3] = " ";
data[4] = " ";



here's my confusing code..well, it worked once or twice..i think before i changed something..
Expand|Select|Wrap|Line Numbers
  1.  
  2. public void moveEntry(String[] data, String check) {         
  3.    int result = 1;          
  4.    int count = data.length - 1;          
  5.    int ctr = 0;             
  6.   for (ctr = 0; result != 0 && ctr < count;)  {            
  7.      result = check.compareToIgnoreCase(String.valueOf(data[ctr]));             
  8.         if(result == 0)  {                 
  9.               for(int ctr2=0; ctr2 < count; ctr2++) {                         
  10.                     data[data.length] = "";
  11.                      data[ctr2] = data[ctr2 + 1];
  12.               }                 
  13.          }             
  14.          else
  15.          {                 
  16.              ctr++;             
  17.          }               
  18.     }           
  19. }
  20.  
Nov 2 '08 #1
2 1481
JosAH
11,448 Expert 8TB
here's my confusing code..well, it worked once or twice..i think before i changed something..
That's an easy one: undo those changes and restart from there. btw. have a close
look at line #10: it causes an ArrayIndexOutOfBoundsException.

kind regards,

Jos

ps. what is so humourous about that crappy code?
Nov 2 '08 #2
rei008
7
That's an easy one: undo those changes and restart from there. btw. have a close
look at line #10: it causes an ArrayIndexOutOfBoundsException.

kind regards,

Jos

ps. what is so humourous about that crappy code?

w0w...data.length..oh yeah..thanks very much..it's working now.. :D
Nov 2 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jack A | last post by:
OK Guys. I'm fed up of the query below taking too much time. I CANT change the query since it is generated by a 3rd party product. I can change indexes and add new indexes though. The schema of...
41
by: Psykarrd | last post by:
I am trying to declare a string variable as an array of char's. the code looks like this. char name; then when i try to use the variable it dosn't work, however i am not sure you can use it...
3
by: Ironside | last post by:
Can someone give me a basic script example for arranging thumbnails on a page. I have always put them in tables that CSS is obviously better. Also, I like to put writing underneath the thumbnails...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
1
by: John Smith | last post by:
I have a two dimentional char array. Before filling it using strtok(), I reset its elements to '\0' using two nested for loops. The code works as I hope it would but I wonder whether I really need...
2
by: Thomas Connolly | last post by:
Anyone know if there is a C# equivallent to: enum { LIFFE_SIZE_AUTOMARKETREF = 15 }; typedef char LiffeAutoMarketReference ; Thanks,
3
by: Sigmathaar | last post by:
Hi, I'm need some advice about lists and vectors. I'm doing a program who needs to have sequential access of a non ordered unit of objects whose size decreases almost each time the sequence is...
6
by: Hemant Shah | last post by:
Folks, I am having trouble with a query. DB2 does not use index, it does relation scan of the table. I am running DB2 UDB 8.2 on Fedora Core release 4 (Stentz) # db2level DB21085I ...
6
by: xansar | last post by:
I have searched through Google for about an hour with nothing to show for it. I'm pretty sure I'm doing the actual return part right, but I'm not too sure what to do with the return once it's back in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.