Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

判断十六进制 #54

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/main/java/com/github/hcsp/calculation/Solution.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,19 @@ public static void main(String[] args) {

// 一个合法的十六进制的字符是:字符0-9,以及字符A/a/B/b/C/c/D/d/E/e/F/f (大小写都是合法的)
// 编写一个方法,给定一个字符,若是合法的十六进制字符,返回true,否则返回false
public static boolean isValidHexCharacter(char ch) {}
public static boolean isValidHexCharacter(char ch) {
if (ch == '0' || ch == '1' || ch == '2' || ch == '3' || ch == '4' || ch == '5' || ch == '6' || ch == '7' || ch == '8' || ch == '9'){
blindpirate marked this conversation as resolved.
Show resolved Hide resolved
return true;
}else if (ch == 'A' || ch == 'B' || ch == 'C' || ch == 'D' || ch == 'E' || ch == 'F'){
return true;
}else if (ch == 'a' || ch == 'b' || ch == 'c' || ch == 'd' || ch == 'e' || ch == 'f'){
return true;
}

return false;
}
}

interface ValidHexChar{
boolean isHexChar(char ch);
}