Search:
Type: Posts; User: cma
Search:
Search took 0.18 seconds.
-
September 26th, 2005, 09:28 AM
Using JOptionPane to get input is pretty simple:
String input = JOptionPane.showInputDialog("Enter a number");
int number = Integer.parseInt(input);
That's your input routine for reading in...
-
September 14th, 2005, 10:12 PM
In terms of this example, no, there shouldn't be any huge performance difference. The Scanner class is actually a new class that they added to the latest version of Java. I'm guessing many course's...
-
September 14th, 2005, 06:37 PM
That is most likely happening because you're storing the data as String's. Instead, convert it to integers using Integer.parseInt() before adding it to the ArrayList:
BufferedReader inReader =...
-
August 5th, 2005, 03:59 PM
I assume you mean the curly braces ({}). In the code snippet you posted, they mean initialize the array with the following values.
-
July 23rd, 2005, 10:48 PM
An interface is sometimes called an "ultimate abstract class" because it (usually) contains nothing but implicit abstract methods. In general, an interface defines a set of behaviors for class's that...
-
July 23rd, 2005, 10:38 PM
For sorting, try http://en.wikipedia.org/wiki/Sorting_algorithm and http://linux.wku.edu/~lamonml/algor/sort/
The 2nd link contains code in C though, but it's very similiar to Java.
-
July 20th, 2005, 10:25 PM
A RuntimeException like ArrayIndexOutOfBoundsException generally means your code is flawed and has a bug.
Every array has a length field that you can use to check the index against:
int i =...
-
July 14th, 2005, 10:55 AM
It can get a little confusing, some of the explanations out there are unfortunately not very clear about what they're referring to. The links below should help you out a bit.
...
-
July 13th, 2005, 10:05 PM
This would depend on the implementation, if you do a linear seach going towards the first element to find the insertion point, then yes, if you do a binary search, then no.
-
July 13th, 2005, 07:59 AM
The first step of constructing the heap can be done in linear time. The second operation of putting the elements in place would take O(n*log(n)).
Keep this in mind about sorting algorithms and...
-
So you want to do a linear search through the ArrayList to search for 2 String values. There's no need to code an explicit loop to search through the List since the code is already given to you in...
-
There's an option, when you install the J2SE SDK, to also include the source code for the Java library during installation. After installation, open the zip file called src.zip in the folder where...
-
Here's a page with some info about the String literal pool: http://www.javaranch.com/journal/200409/ScjpTipLine-StringsLiterally.html
-
June 22nd, 2005, 03:20 PM
operator<< is a function, the order of evaluation for function arguments are undefined: http://www.research.att.com/~bs/bs_faq2.html#evaluation-order
If you want to know why your compiler is...
-
June 21st, 2005, 02:54 PM
Not exactly, ArrayList's get() method runs in constant time (http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html). Using a linked list just because you need extra space would violate...
-
June 19th, 2005, 10:49 PM
There's also Boost Variant and Boost Any with included usage examples.
-
June 19th, 2005, 02:10 PM
LinkedList's don't support the notion of constant-time random-access. This means that in order to access any element in the linked list, there's code that has to traverse the list until it comes to...
-
June 17th, 2005, 10:36 PM
How about using something like a List, and calling toArray() when needed? A List container, like an ArrayList, will take care of all the internal array management.
List lst = new ArrayList();...
-
June 17th, 2005, 10:21 PM
Are you saying you add 3 items to the HashMap and can only examine 2 when you iterate through it? Or are you just basing this on what the debugger is showing you?
If it's the first one, then...
-
June 14th, 2005, 09:17 AM
There are a few old forum posts that deals with transferring data over sockets, such as: http://www.codeguru.com/forum/showthread.php?t=283663
Transferring data over a network is not that much...
-
June 13th, 2005, 07:57 PM
The Java Tutorial happens to have a few examples: http://java.sun.com/docs/books/tutorial/networking/index.html
-
June 11th, 2005, 12:22 PM
First, use the proper algorithm, search() is used to find subsequences: http://www.sgi.com/tech/stl/search.html
find() is what you're looking for when searching for 1 element:...
-
Here's Stroustrup's FAQ entry about static_cast:
http://www.research.att.com/~bs/bs_faq2.html#static-cast
-
http://www.codeguru.com/forum/showthread.php?t=284510&highlight=sorting+hashmap
-
Here's an online text on compiler theory that use's C++: http://www.scifac.ru.ac.za/compilers/
Another book you may want to look into is Writing Compilers and Interpreters
|
Click Here to Expand Forum to Full Width
|