Recent Posts
-
Synchronous code block to achieve multi-threaded secure ticketing case
Class tickets implements the runnable interface: /** use the synchronization method to solve the thread safety problem…… -
Input positive and auxiliary numbers from the keyboard, count the number of positive and negative numbers respectively, and calculate the sum of all numbers
The code is as follows: /*Input positive and auxiliary numbers from the keyboard, count the number of positive and neg…… -
Practice using enumeration to display traffic light colors
The code is as follows: //Practice using enumeration to display traffic light colors class demo11 {public static void …… -
Array fill
import java.util.*; public class array_fill { public static void main(String[] args) { int array[]=new in…… -
Serialization and deserialization of objects
Person_ Class 1: import java. io. Serializable; public class Person_ 1 implements Serializable { private String name; …… -
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…… -
Practice defining class student classes
The code is as follows: (use member variables defined in other classes in one class) package demo04; /* * Define class…… -
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…… -
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…… -
Multi thread ticketing case
Tickets implements runnable: Public class tickets implements runnable {/ / define the ticket source that can be sold p…… -
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…… -
This call between constructor methods
Person class: /** this can be called directly in the constructor * / public class person {private string name; private…… -
Practice birth days
The code is as follows: import java. text. SimpleDateFormat; import java. util. Date; import java. util. Scanner; // C…… -
Inventory case – Set + method
The code is as follows: Commodity category: /** define and describe the class of the commodity * commodity: 4 attribut…… -
Method overloading
class MyClass{ int height; MyClass(){ System.out.println("无参数构造函数"); height=4; } …… -
Enter the coordinates of two points from the keyboard to calculate the distance between the two points
The code is as follows: import java. util. Scanner; Class demo5 {public static void main (string [] args) {scanner SC …… -
Multi branch practice stone scissors cloth
The code is as follows: /*Multi branch practice stone scissors paper randomly generates a number of 0 / 1 / 2 represen…… -
Enter a grade from the keyboard and judge the grade corresponding to the grade (if branch statement)
The code is as follows: /*Enter a grade from the keyboard and judge the grade corresponding to the grade * / import Ja…… -
Find duplicate elements in an array
public class array_findDupicateInArray { public static void main(String[] args) { int[] array={1,2,5,6,7,9…… -
Input a decimal number from the keyboard and output its binary number
The code is as follows: /*Input a decimal number from the keyboard and output its binary number * / import Java util. …… -
Date class and its methods
The code is as follows: import java. text. SimpleDateFormat; import java. util. Date; Public class datedemo {/ / get t…… -
Interface exercises, teacher student
Working class: /** encapsulate this function in an interface * / public interface working {void sendad(); / / the meth…… -
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)…… -
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…… -
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…… -
Thread waiting and wake-up cases
Define resource classes: /** define a resource class with two member variables * name, sex * and two threads to operat…… -
Array sorting, element search and element addition
import java. util. Arrays; public class array_sort { public static void main(String args[]) throws Exception{ …… -
Merge arrays using collections
import java.util.Arrays; import java.util.Set; import java.util.HashSet; public class array_union { public static…… -
Define a method to return the corresponding grade according to the score
import java. util. Scanner; } -
Thread pool-1
Subclass implementation interface: public class ThreadPoolRunnable implements Runnable { } Test class: import java. ut…… -
Array inversion
import java.util.ArrayList; import java.util.Collections; public class array_reverse { public static void main(St……