|
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.
|
|
|
|
|
|
I found this on W3 school.But there is no mention about space character.
Whitespace characters can be:
A space character // What is symbol for this?
A tab character // like this has a symbol \t
A carriage return character
A new line character
A vertical tab character
A form feed character
My question is what is the symbol for space character if it is whitespace character?
|
|
|
|
|
A space character is literally a single space: " " , ASCII code 32.
Technically, you could encode it as "\u0020" . But there's no need to do that, unless you want to deliberately make your code less readable.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You mean space between double quotes " " is symbol for space character?
|
|
|
|
|
The character you get when you press the space bar on your keyboard is a space character.
What sort of "symbol" were you expecting to see for it?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
understood.
No, I thought that if \t is used for tab character(which is a whitespace character), then this sort of symbol might be for space character too.
That's why I asked.
thanks,
|
|
|
|