The Artima Developer Community
Sponsored Link

Java Answers Forum
java problems

5 replies on 1 page. Most recent reply: Aug 5, 2003 10:38 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
alyla

Posts: 3
Nickname: alyla
Registered: Aug, 2003

java problems Posted: Aug 2, 2003 12:18 PM
Reply to this message Reply
Advertisement
can someone please help. I'm taking an intro to java class, and I can't do it anymore. I have no clue where to even start. I have two programs left to do before the end of the course. One is due by midnight(eastern) tonight, and the other is due by midnight(eastern) next week. If anyone can help me out, please email me at Alliebee2@yahoo.com. I really need help with this, it's an online course and I don't have anyone else to help me with it.

Thank you so much!!!
allie


David

Posts: 18
Nickname: malven
Registered: Jul, 2003

Re: java problems Posted: Aug 3, 2003 6:20 AM
Reply to this message Reply
Well, what are you asking for? You haven't even stated what the problems are that you are trying to solve.

alyla

Posts: 3
Nickname: alyla
Registered: Aug, 2003

Re: java problems Posted: Aug 3, 2003 7:30 PM
Reply to this message Reply
sorry, i was in such in crunch to get that one done that i completely forgot. the last on is as follows:

design and implement an insertion sort hat operates on a linked list of nodes that each contain an integer.
I have a basic idea of how to do it. this is what i have so far.

public void insertionSort(Comparable a[])
{
for (int i=1; i<a.length; i++)
{
Comparable val = a;
int k=i;
while (k>0 && val.compareTo(a[k-1])<0)
{
a[k] = a[k-1];
k--;
}
a[k]=val;
}
}

David

Posts: 150
Nickname: archangel
Registered: Jul, 2003

Re: java problems Posted: Aug 4, 2003 2:20 AM
Reply to this message Reply
So what's the problem?

alyla

Posts: 3
Nickname: alyla
Registered: Aug, 2003

Re: java problems Posted: Aug 4, 2003 5:39 AM
Reply to this message Reply
I guess I don't understand the part about the linked list of nodes containing integers. Is that the same as having an array with integers stored in it? will the code I have do what the problem is asking for?

Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: java problems Posted: Aug 5, 2003 10:38 AM
Reply to this message Reply
Comparable is an interface.
Objects that implement it, implement the following method:
int compareTo(Object o)

The interface compares two objects for establishing order.

int variables are primitives.

In order to compare objects, int values must be converted to Integer objects.

int n = 14;
Integer nI = new Integer(n);

n is a primitive and can not be compared
the object nI is an object and can be compared.

Flat View: This topic has 5 replies on 1 page
Topic: Trying to write a date program Previous Topic   Next Topic Topic: im getting a null pointer exception

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use