CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: cma

Page 1 of 30 1 2 3 4

Search: Search took 0.08 seconds.

  1. Replies
    4
    Views
    1,147

    Re: Simple Addition Progs

    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...
  2. Thread: ArrayList Sorting

    by cma
    Replies
    4
    Views
    1,912

    Re: ArrayList Sorting

    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...
  3. Thread: ArrayList Sorting

    by cma
    Replies
    4
    Views
    1,912

    Re: ArrayList Sorting

    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 =...
  4. Replies
    2
    Views
    1,167

    Re: what does this mean? new String() {...}

    I assume you mean the curly braces ({}). In the code snippet you posted, they mean initialize the array with the following values.
  5. Replies
    3
    Views
    4,324

    Re: defination of interface,abstract

    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...
  6. Replies
    2
    Views
    684

    Re: searching and sorting

    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.
  7. Replies
    2
    Views
    970

    Re: How to check Exceptions while running

    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 =...
  8. Replies
    7
    Views
    2,234

    Re: java is pass by refference or value

    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.
    ...
  9. Thread: heapsort

    by cma
    Replies
    7
    Views
    3,134

    Re: heapsort

    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.
  10. Thread: heapsort

    by cma
    Replies
    7
    Views
    3,134

    Re: heapsort

    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...
  11. Replies
    9
    Views
    1,549

    Re: and statement for a for loop

    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...
  12. Replies
    2
    Views
    968

    Re: Basic question on random

    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...
  13. Replies
    9
    Views
    10,711

    Re: what is string pooling

    Here's a page with some info about the String literal pool: http://www.javaranch.com/journal/200409/ScjpTipLine-StringsLiterally.html
  14. Replies
    37
    Views
    4,520

    Re: What is the Output of this program?

    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...
  15. Re: What's the difference between LinkedList and ArrayList?

    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...
  16. Thread: void* in a struct

    by cma
    Replies
    26
    Views
    2,427

    Re: void* in a struct

    There's also Boost Variant and Boost Any with included usage examples.
  17. Re: What's the difference between LinkedList and ArrayList?

    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...
  18. Thread: Arrays

    by cma
    Replies
    1
    Views
    822

    Re: Arrays

    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();...
  19. Replies
    7
    Views
    2,612

    Re: HashMap replaces pair key/value, why?

    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...
  20. Replies
    3
    Views
    1,670

    Re: Java and sockets help

    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...
  21. Replies
    3
    Views
    1,670

    Re: Java and sockets help

    The Java Tutorial happens to have a few examples: http://java.sun.com/docs/books/tutorial/networking/index.html
  22. Re: How to use find() to find a struct member in vector?

    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:...
  23. Replies
    4
    Views
    934

    Re: Casting:types and advantages

    Here's Stroustrup's FAQ entry about static_cast:
    http://www.research.att.com/~bs/bs_faq2.html#static-cast
  24. Replies
    1
    Views
    18,026

    Re: sorting the hashmap values

    http://www.codeguru.com/forum/showthread.php?t=284510&highlight=sorting+hashmap
  25. Replies
    19
    Views
    4,150

    Re: graduation thesis help on compiler.

    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
Results 1 to 25 of 737
Page 1 of 30 1 2 3 4





Click Here to Expand Forum to Full Width

Featured