Skip to content

Commit e34296d

Browse files
refactor 405
1 parent 20f20c6 commit e34296d

File tree

1 file changed

+11
-8
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+11
-8
lines changed

src/main/java/com/fishercoder/solutions/_405.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ All letters in hexadecimal (a-f) must be in lowercase.
3131
*/
3232
public class _405 {
3333

34-
public String toHex(int num) {
35-
char[] hexChars = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
36-
String result = "";
37-
while (num != 0) {
38-
result = hexChars[(num & 15)] + result;
39-
num >>>= 4;
34+
public static class Solution1 {
35+
public String toHex(int num) {
36+
char[] hexChars =
37+
new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
38+
'e', 'f'};
39+
String result = "";
40+
while (num != 0) {
41+
result = hexChars[(num & 15)] + result;
42+
num >>>= 4;
43+
}
44+
return result.isEmpty() ? "0" : result;
4045
}
41-
return result.isEmpty() ? "0" : result;
4246
}
43-
4447
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy