JAVA Watch(1.1)
JAVA coding for your watch. Tips or feedback to make this watch face better are welcome.
Compatible with
Features
Explore more
- Published on Sep 4, 2022
- ยฉ 2022 MelloGod. All rights reserved.
Comments (2)
Anastasia
Great idea, but there are some inaccuracies in the code:
1. Missing parentheses in the method declaration
Fragment: public static void watch
Reason: A method declaration must always include parentheses () for parameters (even if empty). Without them, it's a syntax error.
Fix: public static void watch()
2. Incorrect type and format for the time value
Fragment: int time = 10:10:45;
Reason: The int type cannot hold values with colons. A colon is not a separator for numeric literals in Java. If you need a time of day, use a String or LocalTime. If you need a timestamp, use long with a numeric value (e.g., System.currentTimeMillis()), but 10:10:45 is not a valid number.
Fix: For time of day: String time = "10:10:45"; For timestamp: long timestamp = System.currentTimeMillis();
3. String literal missing quotes
Fragment: String date = Sun Sep 04;
Reason: String literals must be enclosed in double quotes. Without them, the compiler looks for undeclared variables.
Fix: String date = "Sun Sep 04";
4. Incorrect expression for the battery value
Fragment: int battery = 100/100;
Reason: Integer division yields 1, not the textual representation "100/100". If you want to display a fraction "out of one hundred", the int type is not suitable.
Fix: For display as a string: String battery = "100/100"; For a numeric percentage: int battery = 100;