This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Not Compiling > problelm Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Not Compiling > problelm " Watch "Not Compiling > problelm " New topic
Author

Not Compiling > problelm

Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Hi all,

Can anyone help me with the following problem ?

Mainly, in my program, I have to classes. One of which contains all the methods that will be applied in a Dictionary of type ArrayList and the other one is the call of these methods.

The problem is : when calling these methods - (no thing ) at all happens.
I tried several times to make sure of the code in both classes, but with getting same results each time.

Maryam >
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41630
    
  55
Does "not compiling" mean that there are errors during compilation? If so, which ones?

Also, what does "nothing at all happens" mean - how do you ascertain that they have not effects? Seeing a minimal code example that demonstrates the problem will help us greatly in understanding what the problem is.


Ping & DNS - my free Android networking tools app
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

In fact, what is happening is :

I call the methods (no error) is showing - But :

The result is printed to the console.

So : what do you think ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41630
    
  55
Sorry, not following. What does "The result is printed to the console." mean? Remember that we don't see your code, so we can't say what result -if any- there could or should be.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38513
    
  23
No error printout usually means the program has run correctly. Please provide more details, but it appears your program is actually compiling and running.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

I am not sure what type of detail are you looking for.

But, I will try my best this time :

I have a class : ArrayListDictionary

And : ArrayListDictionaryMainLine

***********************************

Inside of the ArrayListDictionary there are a number of methods that are applied for adding, removing, getting the size of the dictionary .. and so.

And, the other class : ArrayListDictionary : contains methods - calling the previous ones in the ArrayListDictionary.

When calling the findnext method it does not work , meaning the result is not printed in the console .

So : what do you think could be the reason for that ?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38513
    
  23
So you are compiling and running your application successfully after all. You have an error in that method, so please show us the details of the method.

How can anybody help you if you don't give them any correct details?
Sherif Shehab
Ranch Hand

Joined: Mar 05, 2007
Posts: 483

i'm lost , Please provide us with some code snippets to see where is the problems if there are some. Check this ..


Thanks,
Sherif
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

I have this code in my Util class that should sort the array list - However it does not
It does not give any error, but just simply does not perform what it should do .

public static <T extends Comparable<T>> void sort(ArrayList <T> dictWords, int numItems, boolean increasing) {

Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Could anyone think what could be the cause of the problem ?

I really tried hard to figure it out. Even I have already imported the Util package in this class.


>> Remaan
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41630
    
  55
Is there are particular reason for writing your own search routine instead of using Collections.sort, especially if the underlying data structure is a List to begin with?
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

So you're saying that I can use the sort method that is under the Collection interface ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41630
    
  55
Remaan Rem wrote:So you're saying that I can use the sort method that is under the Collection interface ?

Yes, since you're using the compareTo method of the objects in the dictionary anyway.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

But then I will have to implement this interface, is that right ?

I mean my class : say util will have to implement that interface.

What do you think ?
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

And even in such case implementing the interface will cause to : have all of the methods for the collection
interface inside of my class .

Which we shouldn't be doing in this assigment .
Remaan Rem >
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41630
    
  55
No, you don't have to implement any interface, since -according to your code- the elements of the dictWords List already implement it (otherwise you wouldn't be able to use the "compareTo" method). Just try it and see what happens.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36
ya I tried :

dictWords.sort() but I got an error .

What do you think about that ?
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

If that was my code for your suggestion :



I get an error because of the sort method am using .

What do you think about that ? how can I solve that ?
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Now , I tried the Collections.sort(ditWords);

But : the problem is :

I don't have the Two options of the two types of sorting ?

So : do you think that this method : I mean Collections.sort();

Can sort both ways ?

Please let me know as you this


Remaan Rem
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38513
    
  23
No, your Utilitiy class will probably not have to implement the Comparable interface. You have a sort() method in your Utilities class and use that to sort a List.
. . . Utilities.sort(myList);
There is no sort method in the List interface, but it is a static method of the Collections class. Note its generic type is T extends Comparable<? super T>. You can check the syntax from the API documentation. You may need to make your own method generic; you can read about generic methods here.
You should "dump" the List into an array, sort the array, then create and return a new List from that array; there is usually a constructor for most of the classes implementing List<E> taking an E[] array as a parameter.
You should write down the algorithm you are using for sorting on paper, then change all your instructions to shorter and shorter words.

Once you get the way you write your sort in words as short as what you can see now, you can change the whole thing to code very fast.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

Thanks alot Campbell Ritchie .

I really appreciate your help and your time ..

Thanks again >
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Compiling > problelm