C # vs. Java learning: type judgment, class and interface inheritance, code specification and coding habits, constant definitionsType judgment symbol:C#:object A; if (A is int) {} Judged by the IS symbolJava:object A; if (a instanceof Integer) {} is judged by the instanceof symbolClass-To-Interface inheritance:C #: public class Mdatarow:listJava:Publicclass Mdatarow extends arraylistThe common denominato
Chinese character "strict ". You can query a specific symbol table at unicode.org or a special Chinese character table.3. UTF-8 With the popularity of the Internet, a unified encoding method is strongly required. UTF-8 is the most widely used Unicode implementation method on the Internet. Other implementations also include UTF-16 and UTF-32, but are basically not needed on the Internet. Repeat, the relationship here is that UTF-8 is one of the Unicode implementation methods.The biggest feature
encoding to store it. This will take into account the importance of storage space or the efficiency of coding (three common).
1. ASCII code
We all know that ASCII code, a total of 128, with a byte of low 7-bit, 0-31 is the control character Furu space, enter, delete 32-126 is the print characters, can be entered through the keyboard and can be displayed.
Figure 1-ascii Code
2, UTF-16
Speaking of UTF must mention Unicode,iso trying to create a new hy
Java basics ----> Java formatting output, java basics ---- formatting
In JavaSe5, the printf () format output in C language is introduced. This not only makes the control output code simpler, but also gives Java developers more co
Java coding UTF-8, ISO-8859-1, GBK
Java support UTF-8, ISO-8859-1, GBK and other font encoding, the author found that the problem of font encoding in Java is still difficult to fall a lot of programmers, although there are many articles on how to correctly display Chinese Characters in
Causes of Java coding and Solutions
I. file encoding
Unicode is the preferred encoding. Unicode is a global character encoding standard.
Conclusion: the conversion between GBK and unicode is performed through the gbk unicode ing table.
The conversion between UTF-8 and unicode is based on the Conversion rule Formula
Therefore, unicode is the core intermediary. To convert Gbk to UTF-8, convert it to unicode
Java coding in JS
In the current web applications, more and more page elements are operated by js, especially when an asynchronous request is initiated by js, encoding problems often occur. The following describes the Encoding Problems in js.1. Introduce js files externally
Contains string input in a separate js file, for example:
If a script. js script is introduced, the script contains the following code
Coding and decoding of two-dimensional code qrcode in Java
Related to some of the main class library, convenient for everyone to download:
Code Lib:Qrcode_swetake.jar (Website introduction-- http://www.swetake.com/qr/index-e.html)
Decoding Lib:qrcode.jar (Website introduction-- http://sourceforge.jp/projects/qrcode/)
"One", Code:
Java Code Qrcodeencoderhandl
, int[] R3, int[] R4) throws illegalargumentexception{Ensure the arrays is of equal size......}9) ToString methodIn general, each class should define a ToString method:Public String toString () {...}) Main methodGeneral class, consider placing a main () method that contains the code used to test the class, and if it contains the main () method, it should be written at the bottom of the class.4. Java Coding
Java coding specification (2)-General Linux technology-Linux programming and kernel information. For details, see the following section. 6.3 Placement)
Declare variables only at the beginning of the code block. (A block refers to any code contained in braces "{" and .) Do not declare the variable when it is used for the first time. This will confuse unfocused programmers and impede code portability in this
Understanding the basic thread mechanism of java-18.2 from the ground up (6)-using constructors or internal classes to implement multi-thread coding variations
In this section, we will discuss how to use constructors or internal classes to implement multi-threaded coding variations.
1. Basic implementation
package com.ray.ch17;public class Test {public static voi
. */@OverridepublicgetFilethrows IOException { thrownew" cannot be resolved to absolute file path");}Comments on attributes and variables and in-method codeUse // to annotate variables and attributes, and code within methods to use // annotationsIf the non-essential variables and attributes can be commented out, if the code has the responsible logic should be explained by using // annotationspublicServletContextResource(ServletContext servletContext, String path) { // check ServletContext
Learn Java for a few months, has been to public,private,protected,static,final keyword and with each other not too concerned about, today read the "Java Security coding standards" only to find the severity of the problem.Code that does not conform to the rule:A data member of the underlying data type of public (common). Should be changed into private form.Public
we call the second position, the encoding in the page encoding declaration should be the same as the encoding used when the Web page file was saved.
and the browser's coding settings are actually not strict, as we said in the third section, in the browser choose to use GB2312 to view, it will actually still use GBK. And the browser also has the good habit, that it will try to guess what to use the code to see the most appropriate.
I would like to r
. Since I have set the operation as a high-level concept, more work can be done freely at the underlying runtime.
For imperative objects, developers often consider using reusable classes because their language encourages classes as building blocks. Function programming languages tend to reuse functions. Functional Languages construct complex general functions (suchfilter(),map()Andreduce()) And can be customized by functions provided as parameters. In functional languages, it is common to conver
member variable: Need to use GET, set method read, setting9.2. Important or repetitive expressions or methods should be extracted.9.2. Exception handling: Do not ignore any exception information. If you want to track more advanced exceptions, do not ignore the lower level exception information.9.3. Release resources: If you need to release resources, you need to put them in a finally block.Other references:Http://www.oracle.com/technetwork/java/codec
The norm needs to be noticed in the regular coding process, which is a good habit to develop slowly.1. Basic PrinciplesMandatory principle:1. The StringBuilder of the string must be used;The use of 2.try...catchTry {}catch{Exception e e.printstacktrace ();} finally {}// can be used in the outermost action, all other places are forbidden to use;Try { // program code }catch(Exception e) { // is empty, nothing is written } // prohibit use in any
]*):? ([0-9]*)", "selector":"Source.java" "Encoding": "cp936"}Step three: Test 1 public class Foreachtest { 2 public static void Main (String [] args) { 3 string[] books = {" C language "," Java "," Python " 4 for ( String book:books { 5 system.out.printl n (book); 6 7 8 } The results are as follows:Sublime Text2 The Chinese garbled problem solved: In the results if you need to print Chinese, may appear in the Chinese can not prin
/** Coding Specification:* 1, all the names follow the "see the name of the understanding" principle* 2, all the names do not allow the use of Chinese characters or pinyin* 3, Java Engineering naming recommendations using lowercase, such as: OA, CRM, CMS ...* 4, package names use lowercase, for example: Cn.yeah, Com.ali, Com.baidu 、...* 5, the name of the class name, interface name:* 1) The name has only on
(); byte[] bytes4 = S.getbytes ("Utf-16be"); //utf-8 Code Chinese occupies 3 bytes, English occupies 1 bytes for(byteb:bytes4) { //converts bytes to int to be displayed in 16 binary modeSystem.out.print (integer.tohexstring (BAMP;0XFF) + ""); } System.out.println (); /** When your byte sequence is some kind of encoding, this time you want to turn the byte sequence into a * string, also need to use this encoding method, no one will appear garbled*/String str1=NewString
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.