java coding practice

Want to know java coding practice? we have a huge selection of java coding practice information on alibabacloud.com

Java Web practice topic-image management

A large number of images may exist in a website. Some images are the same for all webpages, such as the logo of a webpage and images on the home page. These images are like common HTML files, the processing of these images is usually done by the Web editing tool, that is, it is usually done by the artist. The following HTML Tag is used: SRC specifies the file path and uses the relative path, generally, we create a folder named images in the Web application to store all the images. Generally, th

Java Concurrency Programming Practice Note-happens-before rules

. If operation A is performed before action B and action B is performed before Operation C, then operation a must be performed before Operation C.The following is an English description of happens-before,the Happens-before relation defines when data races take place. An unlock in a monitor happens-before every subsequent lock on the that monitor. A write to a volatile field happens-before every subsequent read of the that field. A call to start () on a thre

Combination of objects in Java concurrency programming practice

Ownership of the stateThe object encapsulates its state, owning the state ownership, which is the ability to change the state, and if the object's reference is published, it is not the ownership of the object's exclusive state, but the ownership of the shared state with the other;2. Instance closure  Object A is enclosed in another object B, and the path to access object A is known to facilitate thread safety, and if the data is enclosed in an object, access to the data is done through methods,

Blue Bridge Cup: Basic practice decimal Turn Hex "Java algorithm implementation"

Title DescriptionA nonnegative integer is given, which is represented as a 16-binary form.Input formatThe input contains a non-negative integer A that represents the number to convert. 0Output formatOutput 16 binary representation of this integerThe problem with the real output if not specifically stated, rounding is done by rounding.Sample input30Sample output1EImport Java.util.scanner;public class Main {public static void main (string[] args) {Scanner cin = new Scanner (system.in); I NT n = ci

Java Practice (iv)--decomposition factorization

Title: Decompose a positive integer into factorization. For example: Enter 90 and print out 90=2*3*3*5.Program Analysis: The decomposition of n factorization, should first find a minimum prime number k, and then the following steps to complete:(1) If the prime number is exactly equal to N, then the process of decomposing the factorization is finished and printed out.(2) if n(3) If n cannot be divisible by K, the first step is repeated with k+1 as the value of K. Public classTest1 { Public voidZh

Java object-oriented practice---Bank business Simulation (array + object-oriented)

enter the country:"); String country = Sc.next (); System.out.print ("\ n Please enter province:"); String province = Sc.next (); System.out.print ("\ n Please enter street:"); String Street = Sc.next (); System.out.print ("\ n Please enter house number:"); String id = sc.next (); System.out.print ("\ n Please enter your account's initial balance:"); Double money = sc.nextdouble (); Address address = new Address(country,province,street,id); User user = new User(code,name

Java Practice---10

1 PackageCn.zrjh;2 3 Public classL {4 5 Public intID;6 PublicString name;7 Public intAge ;8 PublicString City;9 PublicString introduce () {Ten return+ ID + ": under" + Name + ", Christina" + Age + ", lives" +City ; One } A - -}1 PackageCn.zrjh;2 3 Public classY {4 5 Public Static voidMain (string[] args) {6L p1=NewL ();7L p2=NewL ();8L p3=NewL ();9L p4=NewL ();Tenp1.id=100000; P1.name= "Lo Yuanhao"; p1.age=19;

Java error page Practice

If a page does not handle the exception, then the page will be displayed, obviously the user does not want to see this page, then we can jump to a friendly page. IE clever can change other browsers to see the effect. index.jsp errorpage.jsp Java error page Practice

In the Java language: ++a and a++ small exercises & and && small exercises | with | | Little practice Boolean type little exercise

---------------------------------------------------First questionint x = 1,y = 1;if (x++==2 ++y==2)//false True =false; x=2,y=2{x = 7;}System.out.println ("x=" +x+ ", y=" +y);The output is:x=2,y=2---------------------------------------------------Second questionint x = 1,y = 1;if (x++==2 ++y==2){x = 7;}System.out.println ("x=" +x+ ", y=" +y);The output is:X=2,y=1---------------------------------------------------Third questionint x = 1,y = 1;if (x++==1 | ++y==1)//true |  false = true; x=2,y=2

Java Asynchronous Processing Simple Practice

=true; Break; }}}}.start (); } /** * * */ Public voidSendfinish () {sendfinish=true; } /** * * */ Public voidrelease () {System. out. println ("release!"); if(BW! =NULL) { Try{bw.close (); } Catch(IOException e) {//TODO print log. } } //in fact, using queue = null is enough. if(Queue! =NULL) {queue.clear (); Queue=NULL; } } /** * * */ Public voidsendmsg (String text) {if(Text! =NULL!Text.isempty ()) {Queue.add (text);

Practice Java Wait (), notify (), sleep Method--a multi-threaded face question

) {e.printstacktrace (); } } } } After the run, the print results become ACBACB. To avoid this uncertainty related to JVM scheduling. The a,b,c three threads need to be started in a certain order, with the final code as follows: Public classMyThreadPrinter2ImplementsRunnable {PrivateString name; PrivateObject prev; PrivateObject Self; PrivateMyThreadPrinter2 (String name, Object prev, object self) { This. Name =name; This. prev =prev; This. Self =Self ; } @Overrid

Blue Bridge cup Java basic Practice Turtle Rabbit Race Forecast

; - intTime = 0; - while(S1 l) { - if(S1-s2 >= T) {//Rabbit Stop + if((L-S2)/V2 //The turtle reaches the finish line first -Time + = (L-S2)/v2; +S2 =l; A}Else{//The turtle can't reach the end atTime + =s; -S2 + = v2 *s; - } - -}Else{//Rabbits Keep -time++; inS1 + = V1 * 1; -S2 + = v2 * 1; to } + } - if(S1 >S2) { theSystem.out.println ("R"); * System.out.pr

Java Concurrent Programming Practice reading notes (1) thread safety and object sharing

2. Thread security 2.1 What is thread-safeWhen multiple threads are accessed, the program can be " correct ", which is thread-safe.An object that has no status (a class that can be understood as having no fields) must be thread safe.2.2 atomicityIn a typical case, the i++ in a multithreaded state is not secure. Because i++ is actually implemented in a number of steps, the execution of multiple threads can be confusing to each other.Race condition (Race Conditions)Threads and threads need to depe

NOTES: Java Concurrency Practice 2

EXEC2 =NewWithinthreadexecutor (); Public Static voidMain (string[] args)throwsIOException {serversocket socket=NewServerSocket (80); while(true) { FinalSocket connection =socket.accept (); Runnable Task=NewRunnable () { Public voidrun () {//HandleRequest (connection); } }; Exec.execute (Task); } }}classThreadpertaskexecutorImplementsExecutor { Public voidExecute (Runnable r) {NewThread (R). Start (); };}classWithinthreadexecutorImplementsExecuto

Java Concurrency Programming Practice reading Notes (3) Task execution

Similar to the multi-tasking scenario of a Web server, it is not possible to use only one thread to provide services externally. This way, efficiency and throughput are too low.However, it is not possible to create a thread with a single request because the cost of creating the thread is very high and the number of threads that the system can create is limited.So the executor appeared.The meaning of executor frame thread poolThread creation too little wasted server resources, in addition to the

Java Programming (TEN)-----The bowling integral program says that the practice array is really just a math problem for the pit daddy ...

To kneel and beg for a simple way ......... .....Rules.1. This Council once 10 points plus 2 pitches in the back2 This council complements 10 points plus 1 pitches in the back3 this council 2 times less than 10 points that's all.10th round in any case must first cast 2 times 2 times more than 10 points to increase the investment 1 timesOut of 300Package com.lovo;/** * Bowling Credit Program * @author Abe */import Java.util.scanner;public class Bowling {public static void main (STR Ing[] args) {S

Java Theory and Practice: Hey, where's my thread?

When the main thread in a single-threaded application throws an unhandled exception, as the console prints the stack trace (also because the program stops), you are likely to notice. However, in multithreaded applications, especially in applications that run as servers and are not connected to the console, thread death can become a less compelling event, causing local systems to fail, resulting in chaotic application behavior. In the Java theory and

The practice of Redis Pub/sub (subscription and publishing) in Java

such as on are also called subscriptions published to the channel (using the Publish and subscribe commands), in addition to subscription publishing to mode (using Psubscribe to subscribe to a pattern) Subscribe to all CCTV channels 127.0.0.1:6379> psubscribe cctv* Reading messages ... (Press Ctrl-c to quit) 1) "Psubscribe" 2) "cctv*" 3) (integer) 1 When a CCTV1 message is still pushed first, the client receives it normally. The implementation of Pub/sub in

Java Practice question: rabbit problem

Java Practice question: rabbit problem This question is also called the Fibonacci sequence (Fabonacci), the first person to study the series is the Leonardo of Pisa (also known as the Fibonacci), which he used to describe the number of rabbits growing. The first month there are a couple of newborn rabbits. After the second month, they can have babies. Every month a pair of fertile rabbits will be born, and

Easydb-1.0,java Practice Framework

EasyDB-0.1Instructions for useI practiced the use of aJAVAOpen-Source small framework for database interaction. 2015-2-25Welcome everyone to download the use, upgrade.Operation Steps:1. Create a new file in the src directory jdbc.porperties file (file name and location cannot be changed)2. Class Description:3.JavaBean must be a strict standard JavaBean,theset method format must follow the setxxxx () {} style. Otherwise not supported: Http://files.cnblogs.com/files/litaiqing/EasyDB-0.1.zipEasydb-

Total Pages: 15 1 .... 11 12 13 14 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.