1024programmer News Inventory of Java language knowledge (final review) II

Inventory of Java language knowledge (final review) II

🌹Author: Yun Xiaoyi
📝Personal homepage: Yun Xiaoyi’s homepage
📝Github: Yun Xiaoyi’s Github
🤟motto: Dare to face yourself silently by yourself,Strengthening yourself is the core. Don’t wait until you have nothing,before you make up your mind to do it. Plant a tree , the best time is ten years ago, the second is now ! learn to reconcile with yourself , reconcile with the past , ==I hope before spring comes,Let’s face the sea together,Spring is warm and flowers are blooming!==🤟
=🤟
= x1f44f;Column:C++👏 Order 👏👏 column : data structure 👏

Article directory

  • Preface

  • 1. Classes and objects :
    • a. What is the class ? What is the object ?
    • b. Class :
      • The format of (1)class :
      • How to write (2)class?
        • General nouns are defined as member variables (attributes):
        • General verbs are defined as methods (behavior)
          • Example of concretely defined classes

    • c.Object:
      • Create an object
      • How to use the object

  • 2. Constructor :
    • Function :
    • Detailed format &#xff1a ;
    • Classification of constructors :
      • Constructors without parameters
      • Constructors with parameters

    • How to call the constructor ?
    • Note :
    • Example :

  • 3. Interface :
    • a. What is the interface ?
    • b .Format :
    • c. Basic use of interface :
    • d. Relationship between interface and interface
    • e. Interface from JDK 8 At the beginning, 3 new methods were added.
      • 1. The default method : is actually an instance method.
      • 2. Static method
      • 3. Private instance method :

    • f. Note&# xff1a;

  • 4. Case knowledge:Keyboard entry technology
  • 5. Case technology:Random number Random class
    • Function : generate a random number
    • Steps

  • Finally


Preface

Hi everyone , I am glad you clicked on this article , This is the second article of the [JAVA Language Learning] column , This article mainly talks about : class and Object , Constructor , Interface , Case knowledge : Keyboard entry technology , Random number Random class.
Hope you like it, come on insert picture description here

——————————————————————————————————————————————————————————————————————————
#xff1a; Dedicated to me who insists on creating and you who click to open this article and hope to improve All kinds of upsets & #xff0c; Five kilometers are dedicated to treating various internal injuries & #xff0c; After running ten kilometers & #xff0c; the heart is full of openness and kindness.

2. You won’t fall , others will not push you down , you don’t want to stand up ,I can’t afford to be supported by others. The only person who can make you proud is yourself.
Your independence and strength,The knowledge and skills you have learned are your greatest home and glory. The process of hard work is an isolated island,but in the end we must arrive at the shore full of vitality.

3. Never be decadent because of some unworthy things and people , so that your self-improvement is wasted time. Work hard in silence,This is what you need to aim for right now.
Don’t mess it up,No future if you mess up,Go work hard,The end of the trial will eventually be flowers blooming thousands of miles.

1. Classes and objects:

a. What is a class? What is an object ?

A class can be understood as a design diagram (a description of the common features of the same thing) , an object is a specific instance of a class .
Conclusion : In Java , you must first design a class, to create an object and use it.
Insert picture description here

b. class :

(1)class format :

Insert picture description here

Must be modified with private
-- can only be accessed in this interface.
-- Generally used for other default methods or private instance methods in interfaces


/**
1. The default method : is actually an instance method.
-- must be modified with default , default will be public
-- must be called with the object of the implementation class of the interface
*/

default void run(){
go();
System.out.println ("==Running thief==");
}
/**
2. Static method
-- must be static modified , default will have public
-- must be called by interface name
*/

static void inAddr(){
System.out.println("We are a dark horse");
}
/**
3. Private Instance method:
-- must be modified with private
-- can only be accessed in this interface.
-- Generally used for other default methods or private instance methods in the interface
*/

private void go(){
System.out.println( "Start running~~");
}
}

Add three methods for Java's own use. In order to facilitate project maintenance.
We only need to know that there are these three methods, and understand that the characteristics will be accessed.

f. Note :

1, interfaces cannot create objects
2, a class implements multiple interfaces, the specifications of multiple interfaces cannot conflict
2, a class implements multiple interfaces , the same static method in multiple interfaces does not conflict.
3, a class inherits the parent class , and at the same time implements the interface , there are methods with the same name in the parent class and interface, The parent class is used by default.
4, a class implements multiple interfaces , there are default methods with the same name in multiple interfaces , may not conflict , this The class can override this method.
5, One interface inherits multiple interfaces,There is no problem,If there is a specification conflict in multiple interfaces, multiple inheritance cannot be performed.

4. Case knowledge:Keyboard entry technology

1. Package import(automatic package import): import java.util.Scanner;
2. Create a scanner object :Scanner sc = new Scanner(System.in);
3. Waiting to receive user data:int age = sc.nextInt();
4. Waiting to receive user data :String name = sc.next();

>5. Case technology :Random number Random class

Function :Generate a random number

Step

1 , import package (automatically done:) import java.util.Random;
2. Create random number object :Random r = new Random();
3. Start to get random numbers : int data = r.nextInt(10); // 0 - 9

Finally

Thank you very much for reading it patiently and I can insist on writing it here ,excerpt a few words for you,for you,and for me:
1. I think of a sentence : “The rivers and lakes do not believe in tears , society does not sympathize with the weak.” Life will not give because of your fragility , Everything you want , and not because of your pain, lower your standards for you. No one cares about the few nights you toss and turn, and no one cares about the few springs and autumns when you are busy. Others only care about whether you are capable or not , What results did you come up with.

2. No matter how turbid the water is & # xff0c; it takes a long time to settle & # xff0c; it will still be exceptionally clear. No matter how stupid a person is & #xff0c; as long as he works hard enough & # xff0c; he can rewrite his fate. Don’t be resentful that the starting point is too low,that’s just the origin of our standing. Life is a long race & # xff0c; some people laugh at the beginning & # xff0c; some people win at the end.

3. I have never met an early riser, hardworking, cautious, honest person,complaining about bad luck . But hard work is something that needs to be settled down and persisted for a long time. The soil it grows in requires a person to fight alone,to endure countless days of loneliness and loneliness. Hearts can be broken,hands can’t stop,what to do,keep moving on despite the breakdown,this is what an adult should have.

Finally, if you think my writing is not bad , please don’t forget to like✌, Favorite✌,Add Follow✌(。・ω・。)

May we work together, towards a better future,May we gradually become big brothers from a rookie who is ignorant. Come on,Like yourself!

�xff1a;Random r = new Random();
3. Start to get random numbers : int data = r.nextInt(10); // 0 – 9

Finally

Thank you very much for reading it patiently and I can insist on writing it here,excerpt a few words for you,yes You , also to me :
1. I think of a sentence : “The rivers and lakes do not believe in tears, society does not sympathize The weak.” Life will not give you everything you want because of your fragility, let alone lower your standards because of your pain. No one cares about the few nights you toss and turn, and no one cares about the few springs and autumns when you are busy. Others only care about whether you are capable or not , What results did you come up with.

2. No matter how turbid the water is & # xff0c; it takes a long time to settle & # xff0c; it will still be exceptionally clear. No matter how stupid a person is & #xff0c; as long as he works hard enough & # xff0c; he can rewrite his fate. Don’t be resentful that the starting point is too low,that’s just the origin of our standing. Life is a long race & # xff0c; some people laugh at the beginning & # xff0c; some people win at the end.

3. I have never met an early riser, hardworking, cautious, honest person,complaining about bad luck . But hard work is something that needs to be settled down and persisted for a long time. The soil it grows in requires a person to fight alone,to endure countless days of loneliness and loneliness. Hearts can be broken,hands can’t stop,what to do,keep moving on despite the breakdown,this is what an adult should have.

Finally, if you think my writing is not bad , please don’t forget to like✌, Favorite✌,Add Follow✌(。・ω・。)

May we work together, towards a better future,May we gradually become big brothers from a rookie who is ignorant. Come on,Like yourself!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/inventory-of-java-language-knowledge-final-review-ii/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索