Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to convert String to Int in Java
How to convert String to Int in Java

Header file: #include

atoi() function is used to convert a string into an integer (int), and its prototype is:

int atoi (const char * str);

Function description atoi() function will scan the parameter str string and skip the preceding whitespace characters (such as spaces, tab indentation, etc., you can use isspace() function to detect), the conversion will not start until it encounters a number or a positive or negative sign, and the conversion will not end until it encounters a non-number or the end of the string ('\0'), and the result will be returned.

The return value returns the converted integer; if str cannot be converted to int or str is an empty string, 0 will be returned.

Extended information:

Java is an object-oriented programming language. It not only absorbs the various advantages of the C++ language, but also abandons the difficult-to-understand concepts such as multiple inheritance and pointers in C++. , so the Java language has two characteristics: powerful and simple to use.

As a representative of static object-oriented programming languages, the Java language perfectly implements object-oriented theory and allows programmers to perform complex programming with an elegant way of thinking.

Java has the characteristics of simplicity, object-oriented, distributed, robustness, security, platform independence and portability, multi-threading, and dynamics. Java can write desktop applications, Web applications, distributed systems and embedded system applications, etc.

Reference material: Java – Baidu Encyclopedia