2,040 Posted Topics
Re: And if it is between O(n) and O(n^2), you can use O(nlogn)... But watch out for O(cn) because it is the same as O(n)... | |
Re: Any reason to revive a 1-year old thread? | |
Re: I don't understand what the meaning of the value inside the array parenthesis? It looks like if there are more than 1 value inside the parenthesis, it is a table. | |
Re: OK, I will simplify it into a mathematic equation for you (a little algebra but at the end it will become arithmatic). Look at the first line in main() `E e = new E(5);`, the value saved in the class will be a constant which will be used in computation … | |
Re: ... deleted so I can prove it first... | |
Re: You do not need to do any sorting before creating an ArrayList. You could simply read the data and try to insert the element at the correct location using add(index, E) to the array list. intArray <- an integer array arrayList <- an empty array list for each element of … | |
Re: You simply copy the value of the aa5 to another new array before you put it in the temp. String[] aa5 = m1.get(key3); String[] newAA = new String[aa5.length]; // create a new array with the same length for(int i=0; i<aa5.length; i++) { newAA[i] = aa5[i]; } // copy each value … | |
Re: Is it a [Combo box](http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html) class you are looking for? | |
Re: When you do a swap, you should not use the `for(int tmp : arr)` or any for-loop because it is ambiguous and won't work with many other cases. What you should do is to directly access the array using array indices. In your case, you have array size of 2 … | |
Re: Please start a new thread, don't hijack other's thread. To answer your question, it means that if 2 lists already have different sizes, it implies that both are not equal (return false). Therefore, you do not need to check each element equality at all. Otherwise, you need to check for … | |
Re: The indexOf() function for string or array returns -1 if not found, not an empty string or null... Your major issue should be with the browser is IE (not sure if the current version still has this problem) because it does not have the build-in indexOf() function. Is that what … | |
Re: >f(x : double) : double >post: return x > >integral(og : double, bg : double, step : double) : double >post : return (f(og) + f(og+stap) + … + f(bg)) * step Your function definition doesn't really make much sense. The f(x) function does nothing but returns the same value … | |
Re: If you are talking about using pure JavaScript to control audio level, I doublt it can because the language is not a audio player... | |
Re: In your first code, take the code line 20 out and place it in line 24... Your method returns a correct number, but you are displaying a minimum number every time it gets change. In other words, the display doesn't affect the return value. | |
Re: >can you explain what you did to make it work? Please read NormR1 link. The index range of an array can be from 0 up to n-1 where n is the size of the array. For example, array size 5 is declared as `int[] arr = new int[5];` will have … | |
Re: It is obvious that you do not understand how internal database works. This may be a problem dealing with database because it is not exactly the same as programming. In SQL, there usually is a unique identification number (ID) created with a table (when someone creates a table), so that … | |
Re: >college academic controlling all departments >i want new ideas to this project in java. How about let one department control all college academic? That would be a new idea. =) | |
Re: I am confused about your approach to the minmax method. Are you trying to evaluate from each slot or from each column? Also, how do you come up with scoring (line 31)? The way you score right now always gives higher score to any odd columns. That's also the problem … | |
Re: Assuming line break is between each name. 1)separate each name using line break delimiter ==> `A_LIST.split(/\r?\n/)` 2)separate each of the name using white spaces ==> `A_NAME.split(/\s+/)` 3)determine what to go using the size of array after splitting 3.1)If the array size is 1, it is the first name (and may … | |
Re: I'm not sure what you really want? Please give us some cases/examples that you want to test. Sometimes, you could use try/catch in the test. When certain values should not be there but it all the sudden gets to there, you could throw an exception. Then catch the exception in … | |
Re: Try to check where the delay is from by adding some println in various places, especially in your finally clause. Try to pin point where exactly is the cause and you should be able to handle that easier. | |
Re: Do you want to keep all as string or else? If they are all string, then in your constructor would be... String[] rowData; public recordRowObject(String[] data) { if (data==null) { throw new IllegalArgumentException("\nData cannot be null!"); } rowData = new String[data.length]; foreach(String s : data) { rowData[i] = s; } … | |
Re: You could do 2 ways, either pass in a string for concatenation and return it at the end, or return a built string plus its own at the end. If you are using a local variable, use it to concatenate with the return value from recursion call. To me, the … | |
Re: Try a syntax error type of error in your code? Add something like `alert('intend to be error'` which would trigger the error of javascript somewhere in your script that it will get call while it is in the loop or so. | |
Re: In your main class, create a GUI using JFrame and a JPanel to accept the inputs from a user. Once you are done with the input, compute and display it out to the same or another JPanel... A very simple JFrame with a button... import java.awt.*; import java.awt.event.*; import javax.swing.*; … | |
Re: It's your homework. Do some google and you should find the exact answers... Also, this is for you to think, not for you to ask for answers. <snip> PS: The format of the code is in C/C++. It is not Java. | |
Re: There is no nextString() for Scanner class ([API doc](http://docs.oracle.com/javase/6/docs/api/)). Use nextLine() or next(), but I prefer nextLine() though. | |
Re: The method name move() looks like it should be called setLocation() instead... To move, it should indicate the number of step moving to x axis and y axis, not assign the value to x and y... If you want it to really call move(), you need to add the incoming … | |
Re: Line 26, you are assigning the *s* which is an object of Scanner class into an int[] datatype. Also, you are using a wrong index. You will get an array out of bound exception as well because array uses 0-index. In other words, an array size *n* will have indices … | |
Re: 1)Line 3, the function must be getElement**s**ByTagName(...) 2)It is not a good idea to create your own customize tag in HTML. If you want a field, use **div** tag instead. 3)You could simply use getElementsByTagName("input") and work only those with type *radio* and the specific name. 4)The *visibility* attribute won't … | |
Re: Not sure about your sorting algorithm. In the algorithm ([WikiPedia](http://en.wikipedia.org/wiki/Insertion_sort)), it starts from a node right after the first one and compares the node value with the previous node value. In your algorithm, you starts from the head and compares the node value with the next node value... | |
Re: I am not sure that a newbie would understand what logic in solving a problem even though the problem is trivia... Anyway, the problem lies in the for-loop condition and how you need to break out of the loop to return a value. Let's talk about the loop first. You … | |
Re: >Problem is at line 32, when i am putting value again in temp from m1, instead of value the location of value of m1 is also replaced. That is exactly what NormR1 said "there is a single object that is used as the value in both HashMaps [or are objects … | |
Re: 1)Next time, **you need to ask the right question. Not just dump your code and expect others to look through for you**. 2)Your insert & remove methods definitions are exactly the same. The only method that has correct definition is the insertAtHead() method. The rest are wrong. 3)Now, ask the … | |
Re: If the question asks for the whole program, then yes (O(3) == O(1)). Though, it is trivia if that is the question. If the problem is asking for the time complexity of the function, that will be a huge difference. The reason is that the function can go into an … | |
Re: Well, how about look at this [link](http://docs.oracle.com/javase/tutorial/2d/geometry/primitives.html) to get start with drawing 2D curved lines? | |
Re: Or pass the value which you want to use in the loop inside to the recursive method. That way, the value will be updated every time you call. // i.e. public simpleRecursive(int val) { if (val>0) { for (int i=0; i<val; i++) { System.out.print(i+" "); } System.out.println(""); simpleRecursive(val-1); } } … | |
Re: Line 14, you are assigning toString() value to the variable *animalName* instead of taking an input from a user. Change it to `input.nextLine()` to get an input from a user after the user press *Enter* key. Line 16, you are adding an empty Animal object (assuming that the Animal class … | |
Re: This is Java forum, not MySql... Anyway, you can use CURDATE(), DAYOFWEEK(DATE), and ADDDATE(DATE, NUMBER_OF_DAYS) functions to do what you want. | |
Re: That's the root directory (where every directory is branched off, read this [intro to unix file system](http://www.december.com/unix/tutor/filesystem.html)). Why would you allow public to read/write the root directory? It is not Windows. What you may need to do is to allow access to a correct directory from the root, not the … | |
Re: Because you use count++ in the if condition, you would confuse yourself. Think about what happen right after the condition? The count value is increased right after the comparison before throwing the exception statement. if (count++ == 0 ) Throw new ThreeException(); // is similar to... if (count==0) { count++; … | |
Re: 1)Your answer is somewhat correct. As nmaillet said, it is difficult to determine what it would be. Assume (or regardless) the *read number* will handle any invalid input in some way and will always return a valid input, your answer would be correct. 2)Let's see how modulo work. If -2 … | |
Re: It depends on how you want to deal with and how each resource becomes available. I don't think there is an absolute algorithm to solve the problem due to so many factors are involved. | |
Re: It is possible but not complete if you have another reference column... Let's say last name. Sort the last name column first, and sort the relationship column second (in the sorting list). The incomplete part is that the daughter who married another family may have her last name changed. That … | |
Re: If I understand you correctly, the program correctly works under GUI mode. But after your create .jar file for the program and runs it under command line, it doesn't work? Do you import any class that aren't in the standard libraries? If not, you may also need to correctly add … | |
Re: Can't pin point the exception cause by looking at that small piece of codes... Usually, it is from a loop that does not end properly. As a result, the program keeps creating references/objects in the memory. I used the word *references* because it includes more than just Java objects. | |
Re: Not exactly sure what you want, but it looks possible. If you want a loading image to mask on top, you could simply overlay or place a component on top of what you want to prevent users to access. Once it is done, remove the component or replace it with … | |
Re: You have a problem understanding scope of variables. Line 6, you call the function (lines 8~13) to compute the value of time. The function return a proper value but you did not store the value in any variable. Then, line 15, you attempt to use variable *time* which is not … | |
Re: The problem is from your Line 6. You hard-coded the size of the array, and then use the value as the max limit of the for-loop. I guess that the *compiler optimization* of Java code changed the code to be a constant instead of keep checking for the array size. … | |
Re: I am guessing you are thinking that `h.username = l.username;` would automatically create a new String object from Login object and store in HomeworkFrame object. I believe that the value is disposed when you do dispose(). One way to try and see if that might be the cause is to … |
The End.