java.lang.arithmeticexception:non-terminating decimal expansion; No exact representable decimal result exception workaround

Today, when writing a Java program, an exception occurred:java.lang.arithmeticexception:non-terminating decimal expansion; no exact representable Decimal result.The statement that found the error is:? 1 foo.divide(bar));

Java Collection Class Rollup

First, collections and arraysAn array (which can store the base data type ) is a container for storing objects, but the length of the array is fixed and not suitable for use when the number of objects is unknown.The length of the collection (

exception handling Mechanisms in Java

exception handling Mechanisms in JavaExamplestatic void main(String[] args) {// TODO Auto-generated method stubString s="hello";int i=Integer.parseInt(s);}}Run Exception results In the above code, integer.parseint means to convert the

Exercises for Java 16-1 ArrayList 1

Demand:ArrayList remove duplicate values of strings in the collection (remove the same string)Analysis:The first approach: Create a new empty collection:A: Create 1 collections with the same stringB: Create a 1 empty collectionC: Iterate through the

On Java exceptions

In this section, briefly talk about exceptions in JavaAn anomaly architecture diagram(From: http://zhidao.baidu.com/link?url=Hvad_t9sT-wsvFHZgM3dSw1CIIPcwMfz-8japqHsAc_ Nij9mmfzjycondyelwrq-g8abcqxvbkwu0wanupsun_)Two ExceptionBy visible exception

Java memory model

Question: In concurrent programming, what mechanisms are implemented between multiple threads for communication (information exchange), and what mechanisms are synchronizing data?Answer: In the Java language, the shared memory model is used to

2016/09/21 Java Keyword final

1.final classThe final class cannot be inherited, there are no subclasses, and the methods in the final class are final by default.The final class cannot be inherited, so the member methods of the final class have no chance of being overwritten, and

Java Basic syntax

A Java program can be thought of as a collection of a series of objects that can work together by invoking each other's methods.Object: Is an instance of a class that has state and behavior. For example, a dog is an object whose state is: color,

Java Learning Note 9.22 (generics)

Generic code vs. virtual machines:Automatically provide original type, erase type variable, replace with qualified type (none with Object)When a generic method is called, the compiler enforces type conversions on the returned objectA generic class

Several ways to implement Java singleton pattern

Singleton mode many books are written in this way:public class SingleTon1 {private SingleTon1 () {}private static SingleTon1 instance = Null;public static SingleTon1 Getinsta nCE () {if (instance = = null) {instance = new SingleTon1 ();} return

Reusability of Java Internal locks (reentrancy)

Java provides an internal locking mechanism that enforces atomicity: synchronized blocks. But an internal lock is reentrant, and the request succeeds when the thread tries to acquire a lock that it itself occupies.Simply put, you can always get the

This and super in Java

1.thisThis is an implicit parameter, which is the constructed object, and we access the instance domain in the same way as this.Public Employee (String name,double salary){This.name=name;This.salary=salary;}Here's a brief look at the difference

Add double type data in Java

Public class doubleplusdouble {    public static double add ( DOUBLEV1,DOUBLEV2) {BIGDECIMALB1  = new bigdecimal (double.tostring (v1));         Bigdecimal b2 = new bigdecimal (Double.tostring (v2));         return b1.add (B2). Doublevalue ();    }  

Methods and Arrays of Java

Method1. Overview of methodsSuppose there is a game program, the program in the process of running, to constantly launch shells. The firing of shells requires writing 100 lines of code, and each time we implement the firing shells we need to write

RSA use of Java encryption and decryption

Recently, in order to analyze a request flow, we have to study RSA encryption.First, emphasize one thing: The key "key" reads "Yue", not "Yao", the amount ...On the Internet on the principle of RSA catch a lot of, here is just a brief talk about my

Java Development POI Read import Excel file and verify

Apache POI is an open source, cross-platform Java API developed by Apache that provides APIs to Java programs for various operations in Microsoft Office format archives. The Excel operation in POI is simple, the main class has

Java-class and Object basics Exercises

1. Create a triangle class, a member variable three sides, a method to find the perimeter, and create a class master Class A to test it. Public class sanjiao{ publicdouble z (double A,double B,double c) { return a+b+C;

Java.util.zip Gets the zip file entry InputStream

Packagecom.test;ImportJava.io.BufferedInputStream;ImportJava.io.ByteArrayInputStream;ImportJava.io.ByteArrayOutputStream;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava.io.InputStre

Java design Pattern--Singleton mode

The singleton pattern, as the name implies, is to ensure that a class is allowed only one instance in the program.   This class can create a unique instance of itself and only provide this unique instance to the system. We usually say that there are

Detailed parsing of java containers

Detailed parsing of java containers In java development, we will certainly use a large number of collections. Here I will summarize the common collection classes, the advantages and disadvantages of each collection class, so that we can better use

Total Pages: 6206 1 .... 2931 2932 2933 2934 2935 .... 6206 Go to: GO

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.