Skip to content

Commit

Permalink
Answer by williamgl (#86)
Browse files Browse the repository at this point in the history
Answer by williamgl (#86)

Co-authored-by: williamgl <ligan@oregonstate.edu>
  • Loading branch information
ByteLegendBot and williamgl committed Nov 23, 2022
2 parents 676cf9b + a5f829e commit 623ab19
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/bytelegend/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@

public class Main {
public static byte int2byte(int i) {
return i;
return (byte) i;
}

public static short int2short(int i) {
return i;
return (short) i;
}

public static char int2char(int i) {
return i;
return (char) i;
}

// Cast an int to String, e.g. 123 -> "123"
public static String int2String(int i) {
return i;
return Integer.toString(i);
}

// Cast a String to int, e.g. "123" -> 123
public static int string2int(String s) {
return s;
return Integer.parseInt(s);
}

// Cast a String to double, e.g. "1.23" -> 1.23
public static double string2double(String s) {
return s;
return Double.parseDouble(s);
}

public static int castLong2int(Long l) {
return l;
return l.intValue();
}

public static long double2Long(Double d) {
return d;
return d.longValue();
}
}

0 comments on commit 623ab19

Please sign in to comment.