|
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,
|
|
|
|
|
|
|
Get Frhed.
You can download it here:
Frhed - Free hex editor[^]
There's so much going on with character encodings in developing software apps on all platforms that having a handy hex editor at you're disposal, especially if you're confused about which way something is going ... is a really good idea.
|
|
|
|
|
There's also the Hex Editor plugin[^] for VSCode[^], in case you need a non-Windows solution, or already have VSCode installed and don't want to install yet another editor.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
In the noted line i have problem.where i am doing error so that i am not getting old address and new address? Rest of the things are showing expected result.
-----------------------------------
public void displayCustomerDetails(Address address) {
System.out.println("Displaying customer details \n***************************");
System.out.println("Customer Id : " + customerId);
System.out.println("Customer Name : " + customerName);
System.out.println("Contact Number :"+ contactNumber);
System.out.println("Customer Address : " +this.getAddress());
System.out.println();
}
public void updateDetails(Address address) {
System.out.println("Updating customer address...");
this.setAddress(address);
System.out.println("New Customer Address :"+ " "+this.getAddress() );
}
My Code
--------------
Customer Class
----------------------
public class Customer {
private String customerId;
private String customerName;
private long contactNumber;
private Address address;
public Customer(String customerId, String customerName, long contactNumber, Address address) {
this.customerId = customerId;
this.customerName = customerName;
this.contactNumber = contactNumber;
this.address = address;
}
public String getCustomerId() {
return customerId;
}
public String getCustonerId() {
return customerId;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public long getContactNumber() {
return contactNumber;
}
public void setContactNumber(long contactNumber) {
this.contactNumber = contactNumber;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
public void displayCustomerDetails(Address address) {
System.out.println("Displaying customer details \n***************************");
System.out.println("Customer Id : " + customerId);
System.out.println("Customer Name : " + customerName);
System.out.println("Contact Number :"+ contactNumber);
System.out.println("Customer Address : " +this.getAddress());
System.out.println();
}
public void updateDetails(long mobile) {
System.out.println("Updating customer contact number...");
this.setContactNumber(mobile);
System.out.println("New Contact Number:"+ " "+this.getContactNumber());
}
public void updateDetails(Address address) {
System.out.println("Updating customer address...");
this.setAddress(address);
System.out.println("New Customer Address :"+ " "+this.getAddress() );
}
}
Address Class
----------------------------
public class Address {
public String homeNo;
private String street;
private String city;
private int pin;
public Address(String homeNo, String street, String city, int pin) {
this.homeNo = homeNo;
this.street = street;
this.city = city;
this.pin = pin;
}
public String getHomeNo() {
return homeNo;
}
public String getStreet() {
return street;
}
public String getCity() {
return city;
}
public int getPin() {
return pin;
}
}
Tester Class
---------------------------------
public class Tester {
public static void main(String[] args) {
Address custAddress = new Address("D109", "Castle Street", "London", 65436);
Customer customer = new Customer("C1016", "Stephen Abram", 7856341287L,custAddress);
customer.displayCustomerDetails(custAddress );
Address newAddress = new Address("D119"," St. Louis Street", "Springfield", 62729);
Long newContact = 7890098656L;
customer.updateDetails(newContact);
customer.updateDetails(newAddress);
}
}
output
--------------
Displaying customer details
***************************
Customer Id : C1016
Customer Name : Stephen Abram
Contact Number :7856341287
Customer Address : Demo1.Address@123a439b // see here it is not printing actual old address:confused:
Updating customer contact number...
New Contact Number: 7890098656
Updating customer address...
New Customer Address : Demo1.Address@7de26db8 // see it is not printing new address :confused:
modified 3-Mar-22 12:09pm.
|
|
|
|
|
|
I have to print old and new address. where my code is wrong?
|
|
|
|
|
You need to provide more details of where you are trying to print these details and what happens. Please edit your original post and add the requested information.
|
|
|
|