Code encapsulation :

In this java Call another class inside the program

stay arrayTool Encapsulate these two functions in .

Compile order :( It can be seen from the following that we should check the syntax before compiling )

To compile the first ArrayTool To compile ArrayOperatorDemo

Because of the compilation ArrayOperatorDemo Syntax checking is done when the file is loaded , Check line nine , Will be in classPath Let's find out if it exists ArrayTool.class file , If not configured classPath Will find... In the current file directory

Whether the class exists . If neither of them , The virtual machine will also go to these two paths to find out whether there is an original file with the same name . namely .java file

A better way to encapsulate code :

Encapsulating functions , add static, Become static , Call... Directly with the class name . And then private the constructor , Prevent the creation of objects .

java More articles on code encapsulation and compilation

  1. [ improve Java Code ] Be careful with dynamic compilation

    Suggest 17: Be careful with dynamic compilation //========= I can't understand this blog for the time being ......... Dynamic compilation has always been Java The dream of , from Java 6 Version, it starts to support dynamic compilation , It can be compiled directly at run time .java file , perform . ...

  2. Yours java The code is right JIT Compiler friendly ?

    JIT The compiler is Java virtual machine ( hereinafter referred to as JVM) It's one of the most efficient and important components of . But many programs don't make full use of JIT High performance optimization capabilities , Many developers don't even know how to use their programs effectively JIT The degree of . In this paper ...

  3. Yours Java The code is right JIT Compiler friendly ?( turn )

    JIT The compiler is Java virtual machine ( hereinafter referred to as JVM) It's one of the most efficient and important components of . But many programs don't make full use of JIT High performance optimization capabilities , Many developers don't even know how to use their programs effectively JIT The degree of . In this paper ...

  4. Java Code encapsulation redis Tool class

    maven Dependency relationship : <dependency> <groupId>redis.clients</groupId> <artifactId>jedis&l ...

  5. mybatis Single table operation is completely realized java Code encapsulation

    Previously used in the project mybtis When operating the database, it is written manually sql, For me sql The level is not very good for people to die of pain : Dynamic query sql I said I can't write yet ! not so bad , Using the reverse generation tool of database table can help me solve most of the problems s ...

  6. java How to be in eclipse Automatically generate code at compile time

    use eclipse Write java Code , Auto compile time , How to trigger an action , This action is to generate the code of this project , And after compiling , The auto generated code is also compiled , java The editor can automatically prompt the newly generated code ? No generation ...

  7. Java Code to bytecode —— The first part

    Java Code to bytecode —— The first part Original address   author :James Bloom translator : Zhang Kun Understanding in Java In the virtual machine Java How code is compiled into bytecode and executed is very important , Because it helps you understand what happens when your program is running ...

  8. How to be in Android Write efficient Java Code

    from :http://www.ituring.com.cn/article/177180 author / Erik Hellman Factor10 Senior mobile development consultant of consulting company , Once worked for Sony Android Team leader ...

  9. 【java】 And java Execution mechanism of code

    To be in JVM In the implementation of java The code has to be compiled as class file ,JDK How will Java Code compiled as class file , This mechanism is often called Java Source compilation mechanism . 1.JVM Defined class File format , But it's not defined as ...

Random recommendation

  1. PDFobject The plug-in USES ,PDF Check the plug-ins online

    1. Introducing plug-ins JS <script type="text/javascript" src="PDFobject.js"></script> ...

  2. Python:XXX missing X required positional argument: &#39;self&#39;

    A little bit of code Bug Sometimes it's very frustrating , A problem that took a lot of effort to figure out , If you don't write it down , It's easy to forget ! Define a class , If used in the following way , It will appear TypeError: testFunc() missin ...

  3. node(websocket)

    websocket It was html5 One of the features of implementing long links under , Currently, it is supported by many browsers . stay websocket Agreement , First, through http Exchange a handshake , Clearly upgrade the agreement to websocket. At the same time, create a TCP passageway ...

  4. dip Full name

    dip The full name is Density-independent pixel, Density independent pixels . A lot of places are mistaken for device independent pixel, Device independent pixels . This is wrong . because dip That is to say dp Can only ...

  5. utilize QT Develop a notepad

    Different from the previous projects that created love , This time we choose the base class as QMainWindow. And then the default directory is Write the code directly to the corresponding file : main.cpp: #include "mainwindow ...

  6. use php Generate word file

    One . use windows It comes with com, And then use php Generate word file <?php $word= new COM("word.application") or die(" ...

  7. module require difference

    LUA modue require package difference 2011-01-19 12:41:35|   classification :  Default category  |   label :lua  package  module  require   load   ...

  8. eclipse Development Groovy Code , And java Integrate ,maven Package compilation

    I tried it today in eclipse It says in it Groovy Code , And do it and Java Code calls each other , Toss and turn and record the process . First of all, I need to give eclipse Install it. Groovy Plug in for , Plug-in address :https://gith ...

  9. ( translate )Objective-C Class properties

    Translated from :Objective-C Class Properties translator :Haley_Wong because Swift 3.0 There are so many exciting new features , It's easy to ignore Objective-C Small changes in . Apple show ...

  10. linux Sync Internet Time

    Input ntpdate time.nist.gov Synchronize network time If not installed :yum install ntpdate result :3 Jun 15:42:39 ntpdate[4721]: adjust time ...