Search:

Type: Posts; User: colerelm

Page 1 of 2 1

1. Thread: Cannot push onto a stack

by colerelm
Replies
1
Views
147

Cannot push onto a stack

For some reason, whenever I try to push my objects onto a stack, I get a null pointer exception. This is what I have:

private Stack<BSTnode<K>> myStack;

private void preOrderTrav(BSTnode<K>...
2. Thread: How to convert an array of integer to generic type?

by colerelm
Replies
2
Views
520

How to convert an array of integer to generic type?

I have an array,
private T[] elements;. I would like to do this ideally:

if(elements[index] == null){
elements[index] = 0;
}
elements[index] = elements[index] + 1;
3. Thread: Working with log math function

by colerelm
Replies
0
Views
282

Working with log math function

I want to output to calculate the following:

0 - (3/6)logbase2(3/6) = 1/2

I have this in my program:

double ratio = 3/6;
x = x - (ratio * (logbase2(ratio)));

which should equal .5 but I...
4. Thread: How to write Entropy class in java?

by colerelm
Replies
2
Views
575

How to write Entropy class in java?

I found documentation for a class that has some methods I really find useful located at this website.

Is the code for these methods publicly accessible through this webpage or should I email the...
5. Thread: Creating an algorithm to do this

by colerelm
Replies
4
Views
401

Re: Creating an algorithm to do this

I've asked myself that many times. This is my train of thought:

"What's the biggest number we have to search for?" --I have a function that will tell me this so I have this part solved.
"How many...
6. Thread: Creating an algorithm to do this

by colerelm
Replies
4
Views
401

Creating an algorithm to do this

I'm struggling to wrap my head around how I could calculate a seemingly simple algorithm and am wondering if anyone can provide some guidance.

I have a 2D array of type int that stores one digit...
7. Thread: Datatable equivalence in Java 6?

by colerelm
Replies
1
Views
991

Datatable equivalence in Java 6?

Does anyone know of any equivalent class in Java that has similar properties of a DataTable from C#?

Transitioning over to Java from C# and was just curious.

Thanks

by colerelm
Replies
4
Views
296

Re: Comparing two objects

What if I have an equals method in my player class but I want to compare two player objects outside that class? How could I, for example, check to see that an element of an array of type player is...

by colerelm
Replies
1
Views
348

Serialization of lists

I have a list which I save by the following:

public void saveList(ArrayUnsortedList<Wrestler> listOfWrestlersToSave) {
System.out.println(listOfWrestlersToSave);
try{...

by colerelm
Replies
4
Views
296

Comparing two objects

I have two objects, player1 and player 2. These two objects have properties: String first name,String last name, double weight and int grade. I want to create a method that takes in a player object...

by colerelm
Replies
2
Views
340

Referring to cases

If I have a switch-case block like:

switch(i){

case1:
blah1;
break;

case2:
12. Thread: Implementing the compareTo method?

by colerelm
Replies
2
Views
407

Implementing the compareTo method?

I have an assignment that's asking me to create a method which "Implements the compareTo method provided by the Comparable interface. Allows two objects to be compared based on sortKey(sortKey is...
13. Thread: How to sort alphabetically?

by colerelm
Replies
2
Views
492

How to sort alphabetically?

If I have a list of strings within an array, say:
[0] = jones
[1] = apple
[2] = struggle
[3] = zebra

How can I alphabetize them and place them into another array, in correct alphabetical order?
14. Thread: Java UML diagram question

by colerelm
Replies
1
Views
444

Java UML diagram question

I have a java program to write and the professor gave us a UML diagram to follow. It all makes sense except for the part where there are dollar signs. What do these dollar signs mean? Here's what it...

by colerelm
Replies
1
Views
458

Big-O Notation question

I am working with this bit of code for this question:

public boolean remove (T element)
// Removes an element e from this list such that e.equals(element)
// and returns true; if no such...
16. Thread: Why does this equal that?

by colerelm
Replies
2
Views
334

Why does this equal that?

Why is it that this method returns true? I'm supposed to write an equals method that returns true if both rectangles are similar (My assumption of a "similar rectangle" is one which has the same...
17. Thread: How to replace dollar signs with ""?

by colerelm
Replies
3
Views
332

Re: How to replace dollar signs with ""?

I tried that...It still didn't work :\

The string value doesn't become changed at all
18. Thread: How to replace dollar signs with ""?

by colerelm
Replies
3
Views
332

How to replace dollar signs with ""?

I have a program that prompts the user for an entry and they could potentially enter in a lot of things, but I want to catch the dollar signs and convert them to "" in terms of strings. I've tried...
19. Thread: Checking if number is in between two other numbers?

by colerelm
Replies
9
Views
4,357

Re: Checking if number is in between two other numbers?

lol that's what im trying to figure out....What I've thought of so far was thinking of it as a distance or absolute value....Or maybe even finding the median between both numbers and going from...
20. Thread: Checking if number is in between two other numbers?

by colerelm
Replies
9
Views
4,357

Checking if number is in between two other numbers?

Say I have three numbers A, B and C. How would I check if B lies between A and C without assuming that A < C or A > C?
21. Thread: Memory space required for java 6 queue

by colerelm
Replies
2
Views
698

Memory space required for java 6 queue

I have a question from my assignment which I don't entirely understand. Can anyone please look at it and see if it's as easy as I thought it was or if I'm wrong, in which case can anyone help? This...
22. Thread: What are the constraints on the argument values?

by colerelm
Replies
1
Views
310

What are the constraints on the argument values?

public static int puzzle(int base,int limit){
if(base>limit){
return -1;
}
else
if(base==limit)
return 1;
else
return base * puzzle(base+1,limit);
}
23. Thread: What would be the output of this?

by colerelm
Replies
2
Views
421

What would be the output of this?

This was a homework assignment given to me and I got the answer (listed later), but I was wondering if anyone could check it over and see if i'm correct:
a)

//Assume that you can store and...
24. Thread: copying and comparing stacks

by colerelm
Replies
1
Views
341

copying and comparing stacks

How would I create a shallow copy of a stack? The interface method which I must implement is:

MyStackInterface<T> copy();
// Returns a shallow copy of this stack

It doesn't make sense to...
25. Thread: Not sure what I'm supposed to do...

by colerelm
Replies
1
Views
302

Not sure what I'm supposed to do...

So today I got this programming assignment which is due in a week but I don't even understand what is being asked of me. Since my professor sucks at getting back to me via email, I have come to the...
Results 1 to 25 of 30
Page 1 of 2 1