How to precede a character Alphabetically? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Please tell me any method or logic to precede characters alphabetically (i.e., get the alphabetic predecessor of a character) eg. predecessor of a is b. I have searched the net but found nothing. Any help would be appreciated.

If you are asking how to get 'a' from 'b', it's quite simple :
char x = 'b';
x--;
System.out.println(x); // prints a

Related

ascii value as string to character in java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I have a String value "\u0004"
I need to convert it to character '\u0004'
I need to store this character back to the string.
How can this be done?
Maybe this is answer you want
// string value that has "\" in front
String s = "\\u0004";
// substring to leave "\u" out
char c = (char)Integer.parseInt(s.substring(2));

Reglar Expression 5 digit number with special character at 3 posistion [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I had requirement to validate 5 digit String with - at third position.
For example i want to validate number like these 12-18 ,20-35,40-45.I need java string for the same
you can use the regex
^\d{2}-\d{2}$
to match , see the regex101 demo

Extracting specific charaters on different lines in Java [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a file "file.txt" in Java. In the file I have the following values:
10 10
3 3 W
MMMMMRM
4 4 R
LRLRLML
I want to read each line and with each character I want to assign them to a variable which I will use for calculation.
Any idea with how I can proceed with?
Thanks
1) You can use a BufferedReader with the readLine() method to read each line.
2) Then you can use split() for each word or toCharArray() for each character.
3) Then assign said character to predefined variables.
It would be helpful if we could see what you've tried so far or if you could give more details on what you are trying to accomplish.

Is there a RegEx that can satisfy all these conditions? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
The user input will only be accepted when,
Only upper case letters 'X','O','D','L','E' are present in the user input.
Any amount of 'O's only when in between 'D's
'DLE' is at the end and not by itself.
'X' counts as anything.
So for example the user input: 'DDLE', 'DOODLE', 'XXXDODOOOODLEDLX' - will work.
But these examples will not work ("error, wrong input"): 'DLE','DOOODLLE' 'DLEDOD'
based on criteria and examples provided
^(?=.+[DX][LX][EX]$)(?!.*[^DO]O+[^DO])[XODLE]+$
^(?=.+[DX][LX][EX]$)(?!.*[^DO]O+)(?!.*O+[^DO])[XODLE]+$
Demo
or depends on your interpretation of "'X' counts as anything" - meaning DOODDLEX is valid
^(?=.+[DX][LX][EX]X*$)(?!.*[^DO]O+[^DO])[XODLE]+$
^(?=.+[DX][LX][EX]X*$)(?!.*[^DO]O+)(?!.*O+[^DO])[XODLE]+$
or as suggested below
^(?=.+[DX][LX][EX]X*$)(?!.*[^DOX]O+)(?!.*O+[^DOX])[XODLE]+$

Why this declaration line does not give any error [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
int [ ] a;
What is happening in this line can anybody describe. It has spaces between [].
You are defining a reference to an array which is presently null, and therefore of undefined size.
This is correct syntax. The spaces in between square brackets are not relevant.
Here is some proper further usage:
int [] a = new int[10];

Categories