|
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-fou
|
|
|
|
|
Hash tables provide a mechanism by which you can create indexed tables in which the index is a value other than a string. Implement and test an integer key Open Address Hash table. Implement the following interface. • String get(int k); • void put(int k, String v); • bool contains(int k); • void delete(int k); • void printHash(); You must provide an interactive or command-line test application for the hash table. Make the hash table 31 entries, and make sure at least one collision occurs in your data input. You must delete some data from your table to demonstrate deletion. (100 points)
Notable to get output. Could you please anyone help me on this
|
|
|
|
|
Nobody is going to do your homework for you. If you don't know where to start, talk to your teacher.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
package classes;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Scanner;
public class Inventory {
private ArrayList <Item> listItems;
public Inventory() {
listItems = new ArrayList<Item>();
readInventory();
}
public void showInventory() {
for (int i = 0; i < listItems.size(); i++) {
System.out.println(i + 1 + ". " + listItems.get(i).getName());
}
}
public Item getItem(int index) {
if (index <= listItems.size()) {
return listItems.get(index);
}
return null;
}
public int inventorySize() {
return listItems.size();
}
private void readInventory() {
try {
File myObj = new File("data/inventory.txt");
Scanner myReader = new Scanner(myObj);
while (myReader.hasNextLine()) {
String line = myReader.nextLine();
String[] data = line.split(",");
String name = data[0];
double price = Double.parseDouble(data[1]);
Item item = new Item(name, price);
listItems.add(item);
}
myReader.close();
} catch (FileNotFoundException e) {
System.out.println("An error occurred. The inventory file not found.");
}
}
}
|
|
|
|
|
Since you didn't supply the exact error message and the line it occurs on, I'm going to take a wild ass guess and say that you don't have a class called Item defined anywhere.
|
|
|
|
|
Item class can be like
class Item {
String name;
double price;
Item( String name, double price) {
this.name=name; this.price=price;
}
String getName() { return name; }
}
|
|
|
|
|
I am developing a web application with JSF and Primefaces and I would like to integrate a simple wiki functionality which consists only of the creation and visualization of content such as course, definition of an object ... etc.
I know that there are open sources for wikis such as JSPWiki, DevWiki, but is there an other simple alternatives such as a dependency that can be integrated into project ?
Thank you for your reply
|
|
|
|
|
This is Parteek Bajpai, BE COMP student of Bharati Vidyapeeth College of Engineering, Lavale, Pune. I am here to post my problem so that anyone can resolve my problem.
import java.util.ArrayList;
import java.util.List;
public class Solution {
public static int first(List<integer> arr, int low, int high, int x, int n){
if(high >= low){
int mid = low+(high+low)/2;
if(mid == 0 || x>arr.get(mid-1) && arr.get(mid) == x){
return mid;
}
if(x > arr.get(mid)){
return first(arr, (mid+1), high, x, n);
}
else{
return first(arr, low, (mid-1), x, n);
}
}
return -1;
}
public static List<integer> relativeSorting(List<integer> arr, List<integer> brr, int n, int m) {
// Write your code here
List<integer> temp = new ArrayList<integer>(m);
List<integer> visited = new ArrayList<integer>(m);
for(int i=0; i
|
|
|
|
|
Apart from the fact that the posted code is incomplete, you have not given any information about what your problem is.
|
|
|
|
|
Hi,
I am new for java. Can anyone share with me how to read the data from database using JDBC and load the data into JTable?
Because i saw most of the sample for JTable is using hard coded data and show the data in JTable or reading the data from database with fix no of row and column or using DefaultTableModal.
May i know that besides using tablemodal, is there any way to display all data to JTable?
I am looking for something the no of row is not fix, it will depend on the no of records in the database to load into it.
Thank You.
|
|
|
|
|
|
|
public class JavaCharacterisWhitespaceExample_1 {
public static void main(String[] args) {
// Initialize three codepoints: cp1, cp2 and cp3
int cp1 = 49;
int cp2 = 121;
int cp3 = 234;
// Check whether the codepoints are whitespaces or not.
boolean check1 = Character.isWhitespace(cp1);
boolean check2 = Character.isWhitespace(cp2);
boolean check3 = Character.isWhitespace(cp3);
// Print the result.
if(check1){
System.out.print("The codepoint \'"+cp1+"\' is a whitespace character.\n");
}
else{
System.out.print("The codePoint \'"+cp1+"\' is not a whitespace character.\n");
}
if(check2){
System.out.print("The codepoint \'"+cp2+"\' is a whitespace character.\n");
}
else{
System.out.print("The codePoint \'"+cp2+"\' is not a whitespace character.\n");
}
if(check3){
System.out.print("The codepoint \'"+cp3+"\' is a whitespace character.\n");
}
else{
System.out.print("The codePoint \'"+cp3+"\' is not a whitespace character.\n");
}
}
}
Output:
-----------
The codePoint '49' is not a whitespace character.
The codePoint '121' is not a whitespace character.
The codePoint '234' is not a whitespace character.
--------------------------------------------------------------------------------------------------------
public class JavaCharacterisWhitespaceExample_2 {
public static void main(String[] args) {
// Initialize three codepoints: cp1, cp2 and cp3
int cp1 = 9;
int cp2 = 10;
int cp3 = 13;
// Check whether the codepoints are whitespaces or not.
boolean check1 = Character.isWhitespace(cp1);
boolean check2 = Character.isWhitespace(cp2);
boolean check3 = Character.isWhitespace(cp3);
// Print the result.
if(check1){
System.out.print("The codepoint \'"+cp1+"\' is a whitespace character.\n");
}
else{
System.out.print("The codePoint \'"+cp1+"\' is not a whitespace character.\n");
}
if(check2){
System.out.print("The codepoint \'"+cp2+"\' is a whitespace character.\n");
}
else{
System.out.print("The codePoint \'"+cp2+"\' is not a whitespace character.\n");
}
if(check3){
System.out.print("The codepoint \'"+cp3+"\' is a whitespace character.\n");
}
else{
System.out.print("The codePoint \'"+cp3+"\' is not a whitespace character.\n");
}
}
}
Output:
-----------
The codepoint '9' is a whitespace character.
The codepoint '10' is a whitespace character.
The codepoint '13' is a whitespace character.
My Question is why 9,10 & 13 are whitespace characters while 49, 121,234 are not, though all of them are number?
|
|
|
|
|
Because they are not numbers, they are characters. The Character.isWhitespace method treats its input parameter as a character. The numbers you are passing in are just the code points for different characters, 49 = '1', 121 = 'y', etc.
|
|
|
|
|
All of them are numbers,right? Then how Java differentiates that which number is representing character & which number is not?
|
|
|
|
|
|
Yes, but a number is just a character that has a particular meaning to a human. In the same way that a letter has a particular meaning. And the only way a computer can tell the difference is by their code points. In the ASCII character set numbers are represented by the code points 0x30 to 0x39.
|
|
|
|
|
You are saying that 9,10,13 represents ascii characters, while 49, 121,234 don't.
Am i right?
|
|
|
|
|
No. They can all be interpreted as ASCII characters. The lower valued ones are in a group of characters used for control, like 9 is the horizontal tab, 10 is line feed, 13 is carriage return. Values of 32 to 126 are normal characters and 127 is Delete.
|
|
|
|
|
Got it! Thanks 
|
|
|
|
|
You are wrong. They all are ASCII characters. But 9,10,13 are not printable, they usually used as the Control characters.
|
|
|
|
|
You can think about what the printer does when it receives each byte. If the value for the byte is to "tab" then no ink is put on the page - hence whitespace. Instead the printer jumps ahead to the next tab position. The tab is an instruction to the printer where to be ready to print next. New Page, New Line, Backspace all are like this too.
If the value is for the letter "A" then this puts ink on the page -- hence it is not whitespace. The "space" character is kind of special in that it prints a "blank" -- the printer's position on the page moves ahead by one character just as if it printed an "A", but of course no ink is put on the page.
Your display can be thought of in the same way as the printer for this discussion.
|
|
|
|
|
Write a java applet program to create multithreads in java using
Runnable interface to do the following on the number taken from user
and set priorities to various threads:
1. One thread display each digit of the inputted number
2. Second thread display reverse of the inputted number
3. Third thread display sum of each digit of the inputted number
|
|
|
|
|
And another one that just posts their homework assignment without asking any kind of question.
|
|
|
|