I have one Insert method One traversal method, with a post-order( I don't know if I need to use pre-order, I'm trying to use a very poor hash function ℎ(xx)= √xx xKK mod 2 where xx is 2012559 and KK=3.14. If ℎ(xx) = 0, my traversal method is pre-order, and if ℎ(xx) = 1 my traversal will be post-order.
I have 4 separated classes, Tree.java, Node.java, Test.java and traversalType.java
package BST;
public class Node {
int data;
Node leftChild;
Node rightChild;
public Node(){
I have one Insert method One traversal method, with a post-order( I don't know if I need to use pre-order, I'm trying to use a very poor hash function ℎ(xx)= √xx xKK mod 2 where xx is 2012559 and KK=3.14. If ℎ(xx) = 0, my traversal method is pre-order, and if ℎ(xx) = 1 my traversal will be post-order.I have 4 separated classes, Tree.java, Node.java, Test.java and traversalType.java
package BST; public class Node { int data; Node leftChild; Node rightChild; public Node(){
I'm finishing my data structures class and looking for internships and trying to prepare myself for real world application of things I've learned. I'm trying to figure out what sort of project I can start or start over winter break that would use the new data structures I've learned (BSTs, Heaps, Hash Tables, etc). We have been implementing these from scratch but would I be using a library for these on the job? If so, should I implement them that way instead? I have a registrar project from my first data structures class where I used a linked list and then an array list to take care of the different students, classes, and instructors. Maybe I should clean that up and just use that?
how these data structures can be used in non-trivial situations and why I should use one over another. I just don't know a good place to start.
query ="Select major_career.Major_Title, career.ISCOTitle,career.FS.... " //only partial, // I swear the query is correct resultSet = statement.executeQuery(query); //this executes it relArr = new ArrayList<String>(); //don't worry it is intialized
In the code below I tried to store the resultset components into the arraylist
int j = 1; while (resultSet.next()) { while(j<=numberOfColumns){ relArr.add(resultSet.getObject(j).toString()); j++; } } // end while
I am not sure whether the arraylist is able to store the result set because when i try to display it like show below it only shows some rows and only the first column
Iterator it = relArr.iterator(); while (it.hasNext()) { System.out.println(it.next());
I want to manipulate the resultset results in my program by copying the resultset values to other datastructures.
I've looked over the concepts of Java programming, tested them in code and i understand most of them. I have a problem when i need to make harder programs , this might be because i dont know design patterns and algorithms.I'm curious what a entry level programmer needs to know to get a job in the field. Right now i was thinking i need to know:
1. The way all big concepts work and most of the keywords.
2. Design patterns.
3. Algorithms.
what i actually need to know for an entry level job and can you tell me which design patterns and algorithms are a must know for that first job. Considering i might have financial problems in the near future this is not a theoretical question, i really need to know what i need to learn in the next 2-3 months to get an entry level job down.
I have three sorting algorithms in which I must count the number of swaps/copies and comparisons. I am meant to only count the swaps and comparisons that involve anything other than indexes as they are too fast to really matter (according to the professor). My counters are in the right position or not. I keep coming up with swaps/comparisons that don't necessarily match the formulas I'm finding for best/worst case. Makes me think that my counters are somehow out of place or that I don't have enough of them.
Insertion Sort:
public class InsertionSort { public static void insertionSorter(int[] array) { int firstValue; // first value in array int scan; // scan array through the array int moves = 0; // number of moves
Every type of controllable object in my game is a type of Entity, and so extends Entity. This is broken down into Ship(s) and Structure(s). But I have different types of structures as well. The problem is that I use an ArrayList<Structure> to store all of a team's structures, but I need to be able to loop through that, and still be able to reference the subclasses of those structures.
For example, I have a JumpGate, which extends Structure. I need to be able to reference a particular JumpGate - as a JumpGate - and not as a Structure. However, the way that I cycle through all of the different types of structures is with an ArrayList<Structure>. I could get around this by having an ArrayList<JumpGate>, however, I would then need a seperate ArrayList for every type of Structure, which would get messy.
So I'm still learning how to save data using Java. I know that saving data is extremely important when it comes to creating video games.
What I have here is this simple program.
Java Code:
import java.util.*; import java.io.*; import java.lang.*; public class Character { private Formatter x; private int roomNum; private boolean[] visited = new boolean[10];
[Code]...
I'm trying to make sure that after I exit the program, joe starts in room 4, not room 1, and that he has visited rooms 1, 2, 3, 4, and 10. I have the save data created, but how do I save an array of boolean values?
I'm just starting out with learning how to process/parse XML data in Java, following online code/tutorials. I am currently only printing out "catalog."
I have created a database driven Java app that i would like to deploy to several PCs. The App uses JReports which only worked when i installed Javac on this laptop. It worked fine within Netbeans but after building it depended on the java compiler and only worked after setting up Path variable..
Will i need to setup the Javac on every machine or is there any way of deploying it easier?
I am making a program to read data from excel files and store them in tables by their IDs. I have managed to read all the data from excel files as a string and store them in a table. But my project is to store them in table by ascending IDs. I have created the comparator in another class but when i call it in the main class nothing happened. The data that I have to store is like the below:
ID Name Salary 50 christine 2349000 43 paulina 1245874 54 laura 4587894 23 efi 3456457 43 jim 4512878
I am trying to write a program that read from a csv file called matches.csv.
A single football match can end with a win or a draw: in first case the winner team get 3 points and the loser none, in the second case of draw each of the two teams get 1 point.
For example, the first line of the file matches.txt is as follow:
This means that a match has been played on the 17/08/2013 where Arsenal scored 1 goal while Aston Villa 3 goals: thus Arsenal got 0 points while Aston Villa 3 points.
How can I structure my output to make it make it read
Position Team Played Points 1 Aston Villa 2 3 2 Liverpool 1 3 3 Arsenal 1 0
import java.io.File;
import java.io.FileNotFoundException; import java.util.Scanner; public class Teams { public static void main(String[] args) { String fileName = "matches.csv"; File file = new File(fileName);
What would be the most effective method to display data grabbed from a web source that is queried every second, for example the most recent EUR/USD price?
I already have access to the data stream, and I've built a simple FXML in javaFX that contains a grid; I'm not sure how to approach putting the live ticking data into the grid so it continues to update as the price changes, for example.
I am trying to get the excel spreadsheet data and converting it in someway to java. I'm looking for something that will print out the java code itself that way I can embed it into future projects.
My assignment is to design a simple GUI calculator using the stack data structure to perform additions, subtractions, multiplications and divisions. But i having error while i press the action there.
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; import java.util.Stack; public class JCalculator implements ActionListener {
I tried working with XML today, since that's what my book teaches. First, I read some data about Product objects that are suppose to represent products with a code, description, and price. That worked fine. Then, I tried creating a writeProducts(ArrayList<Product> products) method, and man it did not go well.
How it works is that there is an ArrayList instance variable in the class that keeps track of all of my products after the readProducts method returns that ArrayList from the XML file. When I ran the method I had a lot of stack traces printed. I then checked the file on a web browser and an editor, and saw it was completely empty. Here's the code:
import java.util.ArrayList; import java.io.*; import javax.xml.stream.*; // StAX API public class XMLTesterApp { private static String productsFilename = "products.xml"; public static void main(String[] args) { System.out.println("Products list:");
I've spent almost 3 hours on googling about java beans and where it is usable. What I've figured out is that a bean has a public non-arg constructor, properties and getters/setters to manipulate them. I also know that a bean contains no logic, only fields. However, I don't fully understand why I need to use beans instead of normal classes even if a class can do the same things like a bean? Are beans used to store data or what?
A method in Java returns a schema. In .net, we use DataTable to get the data from the schema. How to write the following code in Java:
/* Result r = method(); r.DataSchema; */ using (DataTable tbl = new DataTable()) { using (MemoryStream ms = new MemoryStream()) using (StreamWriter sr = new StreamWriter(ms))
I am trying to create a second class in a single java file (first time trying this) and want to use data from the first class in the second class but I am not able to do it. What am I missing :
package simplecommissioncalculation; import java.util.Scanner; // import java.util.Scanner public class SimpleCommissionCalculation { public static void main(String[] args) {
I am currently concentrating on Java programming skills. Right now developing a Energy usecase in Java with Spring framework. Have business requirement to generate data along with outliers. For example, have two parameters called as min and max (centigrates). Generate a file between min and max and store in a file. Atleast need to generate 10 outliers in each 100 records. Outliers should be < min and > max. How to write a java class with this business condition. The file should be like,
Java Code:
Public class DataGeneration(int min, int max) where min = 30 max = 50
I am trying to write a program that read from a csv file called matches.csv.
A single football match can end with a win or a draw: in first case the winner team get 3 points and the loser none, in the second case of draw each of the two teams get 1 point.
For example, the first line of the file matches.txt is as follow:
In the file it contains the following data.
17/08/2013 Arsenal Aston Villa 1 3 24/08/2013 Aston Villa Liverpool 0 1
This means that a match has been played on the 17/08/2013 where Arsenal scored 1 goal while Aston Villa 3 goals: thus Arsenal got 0 points while Aston Villa 3 points.
How can I structure my output to make it make it read
Position Team Played Points
1 Aston Villa 2 3 2 Liverpool 1 3 3 Arsenal 1 0
Java Code:
import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Teams { public static void main(String[] args) { String fileName = "matches.csv";
I written java code in JSP to display data. I know it is bad practice. Actually my Business-service communicates with DB and returning data in the form of MAP. I don't have beans Because the fields in DB is dynamically changing. So, for now I'm retrieving Data by writing Java code in JSP. Is there any other way to display data without writing java code in JSP?