包含标签:Java 的文章
-
Thread waiting and wake-up cases
Define resource classes: /** define a resource class with two member variables * name, sex * and two threads to operat…… -
Define a method to find the maximum common divisor of two integers
import java. util. Scanner; /* * Define a method to find the maximum common divisor of two integers * / public class d…… -
First acquaintance with Java
Theory Experiment [learning purpose] 1.) understand java 2.) create your first java project and be familiar with Java …… -
Collection framework – Landlords game
The code is as follows: import java. util. ArrayList; import java. util. Collections; import java. util. HashMap; /* *…… -
Multi thread ticketing case
Tickets implements runnable: Public class tickets implements runnable {/ / define the ticket source that can be sold p…… -
Define automobile engine class to output automobile information
The code is as follows: public class Demo { public static void main(String[] args) { // TODO Auto-generated method stu…… -
Analog computer USB interface
//Computer class: /** computer class. The computer has a USB slot * / public class computer {private USB; / / indicate…… -
Practice outputting an integer in reverse order
The code is as follows: /*Practice outputting an integer in reverse order, and take out the numbers of bits, tens, hun…… -
Use the calendar class to get the year, month and day
import java.util.Calendar; public class time_Calender { public static void main(String[] args) { Calendar…… -
Implement multithreaded thread
Define a subclass subthread to inherit thread: /** define subclasses, inherit thread * / public class subthread extend…… -
Byte stream copy file – byte stream
} Speed comparison between byte stream and byte copy: One 20m file: byte stream 70mm, byte 40000 mm -
Interface as a parameter and return value of a method
Interface smoking: public interface Smoking { public static final int a=1; public abstract void smoking(); } Student c…… -
Change whole money for change
The code is as follows: /*Change the whole money. If there is a decimal point 2.94, it shows how many 1 yuan, 5 Mao, 2…… -
Static internal class programming exercise
Outer class: Public class outer {int XX = 10; static int YY = 20; / / static inner class static class inner {int ZZ = …… -
Define author book class
Four classes are defined: Publishing House class (defining and displaying publishing house information), author class …… -
Abstract classes are used as parameters and return values of methods
Abstract class animal: public abstract class Animal { public abstract void eat(); } Subclass cat: Subclass dog: Public…… -
Practice calculating different types of car rentals
The code is as follows: Vehicle class: Public class vehicle {/ / return the total rent public double getsum (int days)…… -
Practice defining class student classes
The code is as follows: (use member variables defined in other classes in one class) package demo04; /* * Define class…… -
Several common sorting algorithms in Java
Several common sorting algorithms in Java 1. Sorting is the operation of arranging a string of records incrementally o…… -
Programming to realize “electronic pet mall”
*/ The code is as follows: //Test class Public class demo {public static void main (string [] args) {dog H = new dog (…… -
Define a date class: including three member variables: year, month and day, and the method of displaying the date
*/ The code is as follows: public class Demo { public static void main(String[] args) { Date date1=new Date(1994,5,22)…… -
Interface exercises, teacher student
Working class: /** encapsulate this function in an interface * / public interface working {void sendad(); / / the meth…… -
Find the odd sum of any two number ranges
The code is as follows: /*Find odd numbers such as any two number ranges and * / import Java util. Scanner; Class demo…… -
Implementation of random roll call device
The code is as follows: /** random roll call: * 1 Store name * 2 Preview owner's name * 3 Randomly choose a person's n…… -
Calling exercise of construction method in word parent class
Person class: (parent class) Public class person {private string name; private int age; public person() {this ("Li Si"…… -
About troubleshooting: the main class cannot be found or loaded. Reason: Java Method of lang.classnotfoundexception
The JDK is configured and the code @ h is written_ 419_ 1@ @H_ 419_ 1@ @H_ 419_ 1@ javac Hello. Java also successfully…… -
Date class and its methods
The code is as follows: import java. text. SimpleDateFormat; import java. util. Date; Public class datedemo {/ / get t…… -
Serialization and deserialization of objects
Person_ Class 1: import java. io. Serializable; public class Person_ 1 implements Serializable { private String name; …… -
Practice complete employee classes
Employee class: /** employees* Extraction of commonness * name, number, working method (Abstract) * / public class emp…… -
Enter an integer from the keyboard and judge whether it is positive, negative or 0
The code is as follows: import java. util. Scanner; Class demo7 {@ h_419_10 @ public static void main (string [] args)…… -
Java realizes the addition, deletion, modification and query code of ES database
import com.alibaba.fastjson.JSONObject; import org.elasticsearch.action.bulk.BulkRequest; import org.elasticsearch.act……