Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-01-2007, 06:35 AM
Member
 
Join Date: Jul 2007
Posts: 40
barney is on a distinguished road
Remove the bucket represented by the int from array
Hi, I need to take a char array and an int as parameters and remove the bucket represented by the int from the array. this is what i have so far
Code:
static char[] removeArray (char[] x, int e) { char[] result = new char[x.length-1]; for (int i = 0; i < result.length; i++) { if (i == e) result[e] = if (i < e) result[i] = x[i]; if (i > e) result[i] = x[i+1]; } }
I'm not sure about this part
Code:
if (i == e) result[e] =
how do i tell it to get rid of the char at int e?
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-01-2007, 09:55 AM
Senior Member
 
Join Date: Jul 2007
Posts: 1,144
hardwired is on a distinguished road
Code:
public static void main(String[] args) { String s = "Hello World"; char[] chars = s.toCharArray(); print(chars, " chars"); char[] reduced = removeElement(chars, 9); print(reduced, "reduced"); } static char[] removeElement(char[] x, int e) { char[] result = new char[x.length-1]; for (int i = 0, k = 0; i < x.length; i++) { if (i == e) continue; result[k++] = x[i]; } return result; } private static void print(char[] array, String s) { System.out.print(s + " = ["); for(int j = 0; j < array.length; j++) { System.out.print(array[j]); if(j < array.length-1) System.out.print(", "); } System.out.print("]\n"); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
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

vB 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
how to remove an image icon cecily Advanced Java 1 08-05-2007 05:25 AM
how to remove whitespaces in a text christina New To Java 2 08-03-2007 06:24 PM
Is there a way to remove an option from optionsCollection? schu777 JavaServer Pages (JSP) and JSTL 0 08-02-2007 10:47 PM
how to remove an object from the array list cecily New To Java 3 08-02-2007 03:26 PM
how to remove an old version of JDK tommy New To Java 2 07-30-2007 09:59 AM


All times are GMT +3. The time now is 09:51 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org