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));
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 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
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
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
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
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
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,
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
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
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
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
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
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
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
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;
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
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
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