[Bluej-discuss] Right-click doesn't work
Lon Levy
lxl at oregon.k12.wi.us
Tue May 2 04:55:51 BST 2006
Hi Fatima,
I have four different ways to answer your question.
First, if you are using methods of the LinkedList class, then you can look at the source code (zipped up in the src folder in the Java installation) and see whether or not they are recursive (they are not).
Second, if you want to make use of some of these in recursive methods, then that should not be too difficult. For example, call this method with int big = largest(myList, 0, myList.get(0));
public Integer largest(LinkedList<Integer> list, int currIndex, int big)
{
if (currIndex == list.size())
{
return big;
}
else if (list.get(currIndex) > big)
{
return largest(list, currIndex + 1, list.get(currIndex));
}
else
{
return largest(list, currIndex + 1, big);
}
}
This is not very efficient, but it is recursive. (Learning to use iterators would be more efficient).
Third, if you want to use efficient recursive methods on a linked list, then write your own linked list class that handles the internals recursively. This is a bit challenging, but it can be done. (This is the first thing we do in my second year course).
Fourth, if you are looking for functional recursion with lists, then use a functional language like Scheme. (Sorry, I do not mean to be rude to Java or BlueJ ... but Java is designed with recursion as an afterthought).
Good luck,
Lon.
Lon Levy, MS-CSEd
Computer Science Teacher
Volunteer Computer Club Advisor
Oregon High School
608-835-4469
lxl at oregon.k12.wi.us
non somnos requiem
>>> 200310762 at uaeu.ac.ae 04/30/06 12:48 AM >>>
Dear All;
how I can make LinkedList methods (eg. boolean remove(), add(T o), size(), getLast(), getFirst(),........indexOf(T o)...) in recursive way
any boday can help me??
Regards;
Fatima Qayedi
specialization : E-Commerce.
----- Original Message -----
From: "Naiara S. Pinto" <naiara at mail.utexas.edu>
Date: Sunday, April 30, 2006 3:30 am
Subject: [Bluej-discuss] Right-click doesn't work
> Dear all,
>
> I have a project in BlueJ and something very odd is hapenning: After
> compiling all classes, I can right-click (and run) some of them,
> but not
> others. I don't get the window with the options ("compile", "new
> Object()", etc.). One of the messages in the archives suggest we use
> control+spacebar to run the class without right-clicking, but I
> get the
> same result.
>
> I noticed that when I compile these classes, I get an error
> message saying
> they have "unsafe operations". I am not sure what to do because I
> am not
> getting any error messages. Does anyone have any idea why this
> happens?
> Thanks,
>
> Naiara.
>
>
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss
>
_______________________________________________
mailing list bluej-discuss at bluej.org
To unsubscribe or change your preferences, go to
http://lists.bluej.org/mailman/listinfo/bluej-discuss
More information about the bluej-discuss
mailing list