Well this one works…
double roundOff = Math.round(a * 100.0) / 100.0;
Output is
123.14
Or as @Rufein said
double roundOff = (double) Math.round(a * 100) / 100;
this will do it for you as well.
More Related Contents:
- Difference boolean[] b = {false} vs. boolean b = false? [closed]
- How to instantiate an Embeddable class?
- How do you do a limit query in JPQL or HQL?
- String concatenation in Java – when to use +, StringBuilder and concat [duplicate]
- Using Selenium WebDriver to retrieve the value of an HTML input
- Scanner doesn’t see after space
- Getting strange output when printing result of a string comparison
- How to get a DefaultTableModel object’s data into a subclass of DefaultTableModel
- Eclipse returns error message “Java was started but returned exit code = 1”
- Unable to create Android Virtual Device
- Default fetch type for one-to-one, many-to-one and one-to-many in Hibernate
- How to use BufferedReader in Java [closed]
- Relation between memory host and memory arguments xms and xmx from Java
- UNIX socket implementation for Java? [closed]
- How can I get System variable value in Java?
- JAXB – Property “Value” is already defined. Use to resolve this conflict
- Convert normal Java Array or ArrayList to Json Array in android
- Java String validation using enum values and annotation
- How to send a stacktrace to log4j?
- Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?
- Using JavaFX in JRE 8, “Access restriction” error
- Android app crashes after SDK-tools update version (NoClassDefFound, tool version 22)
- 2 bytes to short
- Displaying changing values in JavaFx Label
- JAXB inheritance, unmarshal to subclass of marshaled class
- How can I write a byte array to a file in Java?
- Spring MVC 4: “application/json” Content Type is not being set correctly
- Determine if a String is a valid date before parsing
- calculate number of weeks in a given year
- Clicking on a drawn object