包含标签:Java 的文章
-
Multi branch practice lottery game, randomly generate two one digit random numbers, and prompt the user to enter the guessed number
The code is as follows: /*Multi branch practice lottery game, randomly generate two one digit random numbers, and prom…… -
Define a method to return the corresponding grade according to the score
import java. util. Scanner; } -
Inventory case – Set + method
The code is as follows: Commodity category: /** define and describe the class of the commodity * commodity: 4 attribut…… -
Read text from character input stream FileReader class
import java. io. FileReader; import java. io. IOException; /* * The character input stream reads text files (only text…… -
Recursive call of exercise method
Five people sat together and asked how old the fifth person was? He said he was 2 years older than the fourth person, …… -
Merge arrays using collections
import java.util.Arrays; import java.util.Set; import java.util.HashSet; public class array_union { public static…… -
Practice birth days
The code is as follows: import java. text. SimpleDateFormat; import java. util. Date; import java. util. Scanner; // C…… -
Nesting of sets
The code is as follows: import java. util. HashMap; import java. util. Map; import java. util. Set; import java. util.…… -
Merge arrays using lists
import java.util.Arrays; import java.util.ArrayList; import java.util.List; public class array_merge { public sta…… -
Array sorting, element search and element addition
import java. util. Arrays; public class array_sort { public static void main(String args[]) throws Exception{ …… -
This call between constructor methods
Person class: /** this can be called directly in the constructor * / public class person {private string name; private…… -
Thread pool-2
Subclass implementation interface: import java. util. concurrent. Callable; /* * The implementation class of callable …… -
Find the difference set between two arrays
import java.util.ArrayList; public class array_diffrence { public static void main(String[] args) { Array…… -
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……