Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Learn More

Bit Puzzle - Java (Basic) certification Solution | HackerRank

1 min read

Note: This solution is only for reference purpose. Feel free to use this solution as inspiration and enhance your knowledge but please don't literally copy and paste the code.


Solution of the problem:



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
public class BitPuzzle {
    public static void main(String[] args) {
        try {
            Float f = new Float("3.0");
            int x = f.intValue();
            byte b = f.byteValue();
            double d = f.doubleValue();
            System.out.println(x + b + d);
        } catch (NumberFormatException exception) {
            System.out.println("ahhhh");
        }
    }
}






Labels : #hackerrank certification ,#java (basic) ,

Post a Comment