I can see your desire to use the Strategy Pattern to fulfill your need of CRUD; however, do not let Design Patterns entice you into doing something that is, programmatically, a poor decision.
When...
Type: Posts; User: kenster421
I can see your desire to use the Strategy Pattern to fulfill your need of CRUD; however, do not let Design Patterns entice you into doing something that is, programmatically, a poor decision.
When...
On any given calendar there are 5 weeks given that 31/7 = 4.42...
A simple way to think of the calendar is that it's like an array: 5 rows, 7 columns;
int[][] dates = new int[5][7];
You...
The easiest way is to use inheritance. The best way is to use object composition.
How will you decide which object you want to cast it into? Why does your "List object" not contain a parameter....
It wont go past 9 because you have a limiting if statement in your logic. Why is it there?
You need to use debug and step through your code, line-by-line. It isn't complicated and should give you a good idea of where you are going wrong. After a cursory look at the code, I can't see any...
In order to create your own hashmap, you need a key->value pair.
This would be helpful:
public class HashMapImp
{
public static void main(String args[])
{
MyHashMap mhm = new...
You should read the entire file into a String and use the replace method for strings.
String (Java Platform SE 6)
Note that since you want to switch tags around you will need to create a temporary...
You left out some key details. What does your constructor for Roster actually do? I see that you define teamRoster in class Roster immediately. Do this in the constructor to ensure that it gets...
Basic String concatenation should do just fine.
Change your \ to / and follow the UNC conventions.
The comparable interface will assist you in comparing objects.
Comparable (Java 2 Platform SE v1.4.2)
You will need to implement the methods in your class BinarySearch when you add the...
What you need to do is implement a Doubly Linked List and ensure that you have add(), insert(), remove() working correctly.
Insertion sort is one of the easiest algorithms to implement.
After...
Apparently, BufferedReader is better for reading line streams from a text file and the limit for strings is 2 billion characters. My suggesstion: read the file one character at a time...
Try using a scanner instead:
Scanner scanner = new Scanner(new File(inFile));
while(scanner.hasNextLine())
{
System.out.println(scanner.nextLine());
}
Using data structures effectively is all about thinking about how a program needs to operate. Yes, arrays do have a fixed size, but you can always create another array.
Consider this example:
...
Using an ArrayList seems like overkill.
I think you should use multiple methods:
int getHighestScore()
Player[] getWinners()
void printWinners()
Inside the getWinners() method, you create...
The first thing you should realize is the "direction" that the active element takes in a multidimensional array when traversing through it.
The 2D array:
int[][] matrix = new int[3][4];...
Mr. 777,
You have a logical error in your post that
'a' is not an object, it is a reference to an object of type A.
You have classes A and B where B is a subclass of A.
In your code, you...
First, read this on Selection Sort: Selection sort - Wikipedia, the free encyclopedia.
Make sure you are following that algorithm.
If the length of the arrary is n, you will make n passes. On...
This site has simple solutions for TCP and UDP servers that you can use to establish if what you are doing is correct.
A Simple Java TCP Server and TCP Client | systemBash
What is the point of this code segment?
After you ask for a palindrome, you assign it to strippedInput and then immediately expect more input. Why?
What if the string has an even number of...
The good thing about Java is that you can break apart large files like the one you are writing into multiple files easily via copy/paste. Java was designed to be an object-oriented language, so there...
Methods do not get "connected". One gets called and can call another.
If I have a class, Foo, and two methods in that class, barOne() and barTwo(), then I can choose to call them like so:
...
While I will concede that the case of a Tree is a good reason to employ this, I cannot think of any reason that a Graph should contain a collection of Graphs. If this is the functionality needed, use...
Maybe I'm a stickler for OOP, but I'll ask anyway.
Why is there a collection of Things inside of class Thing? It's like putting a collection of Computers inside of class Computer. It's possible I...
I'm with copeg