![]() |
| ||
| Bubble sorting hello, guys i have a really stupid problem about characters and string; i dont know which to use. wacko.gif iam bubble sorting for example a name::'( :?: input: dreamincode output: a c d d e e i m n o why does my code in error? my compiler saids the ff: Exception in thread "main" java.lang.Error: Unresolved compilation problems: i try my hardest but as if i try the more error i get. i try to simplify the error like this short so it wouldn't be so complicated. import java.util.Arrays; can you please help me?? i really need your help. Thnks so much |
| ||
| Re: Bubble sorting You need to initialize your character array something like this:- char characterArray[] = new char[charArraySize]; where the "charArraySize" implies the dimension for your array, you can replace it with 10,20, 30 or ask the user to input it. Also how come I do not see the line where you are taking the input from the console ?? |
| ||
| Re: Bubble sorting Quote:
and oh! by the way do is still need to use string ??? because BufferedReader Only reads as String right? so how can i make the string be character.. :-/ for example iam declaring an integer: String = input; how can i make it like a character or should i declare a character directly with out declaring a string??? and if the array is 20 should i write it this way? char characterArray[20] = new char[charArraySize];:icon_question: :confused: iam kinda lost please help further explanation. |
| ||
| Re: Bubble sorting I said char characterArray[] = new char[charArraySize];I had said replace "charArraySize" with the appropriate size. So if your array size is 20 it should be:- char characterArray[] = new char[20]; And no BufferedReader can also read a character at a time. Refer here for more details on that. Heres the javadocs of the String class of Java, it provides a function to export the data in a given String to a char array directly, so you wouldn't even have to initialize the char array the way we have discussed anyways. |
| ||
| Re: Bubble sorting really many thanks to you.. i wish i could do something for you too THAnks so much:) |
| ||
| Re: Bubble sorting >really many thanks to you.. i wish i could do something for you too Well, you could mark the thread as "Solved" and leave him a favorable reputation comment on the post. |
| All times are GMT -4. The time now is 3:48 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC