This is a question on my homework, can anyone help me understand what it saying ? Thanks
"Suppose that you have an ArrayList and that it contains String objects. Which declaration of the ArrayList...
Type: Posts; User: maple1100
This is a question on my homework, can anyone help me understand what it saying ? Thanks
"Suppose that you have an ArrayList and that it contains String objects. Which declaration of the ArrayList...
Solved.
Solved.
Found it. Thanks!
I .add(found) onto the arrayList, is there a way to check if an ArrayList contains elements? Since the "found" only get added when the String match, if there no string match then there be nothing...
I'm working on sequential search and this is my code to search a String. The problem I have is that once the array is found, it stop. I was wondering what if there are more than one occurrence of...
Thanks for the hints on the value of max.
Here is my new code and it working, but I don't understand why the inner loop need to have an index of max which = i for it to work.
public static...
I'm currently doing selection sort and this is my method to sort a array of string into alphabet order. I interpret the code line by line into words and test it by hand it seem to make sense but when...
I'm current doing insertion sorts with ArrayList and I'm getting java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at replace.get(insertindex).setTitle(next); . I understand there is nothing at...
Jaguar: Quantity = 2, Total cost = 2100000.0
Neon: Quantity = 3, Total cost = 52375.32
Jigsaw: Quantity = 1, Total cost = 149.18
RAM: Quantity = 1, Total cost = 35700.0
CircularSaw: Quantity = 2,...
Is there another way to print out the results? That the only wait I could of think, as it complete the inner loop, it print.
Oh, I don't mean to code it for me. I updated the code with the loop going through and keeping the quantity above, but it printing all the items. IE if there 2 item A, it would print item A two time...
Chris, thanks for the reply! Can you give me help on my updated code above? Thanks
takeInventory suppose to keep count of the items that passes through and print their quantity. The result I'm getting is
"guar: Quantity = 2, Total cost = 1110000.0
Neon: Quantity = 3, Total cost...
So do I change it to %5.2d? I still get the error on that.
It not allowing me to print at all, it giving me the error at that line. I think what causing is I don't have a conversion format inside the printf for "(c.get(x).getVotes() / total ))" I do have...
This is part of my code. I'm getting "illegalformatconversion" at the printf statement. How can I change the code so that the third thing it print is the votes / total votes? Thanks
public...
The second indexes should be 1 more than the first, am I correct?
--- Update ---
It work when I set i = x+1. Is this the correct way? Thanks
I understand the starting at another index part but let say I put i=1 instead of 0 , it might not compare itself to thing at index 0 but at index 1 and so on it will compare itself.
This is the nested loop that I have but it also compare the objects to itself since x and i have the same value at some point. How can I avoid the objects inside the list comparing itself? Thanks
...
Would the List that I created with the objects being added fine or do I need to create a different array? Thanks
For the code belong, I'm trying to compare all the objects with each other and print if they're the same, is there any efficient methods in doing so beside me creating like 20 if else statement and...
I forgot about calling the method, I thought it would call itself for some reason. Thanks you so much!
It print out nothing. Since I "setType("Math"); " won't it print out "Math"?
public class testHomework
{
public static void main(String[]args)
{
MyMath math = new MyMath();
System.out.println(math.toString());
}