java test cases

Learn about java test cases, we have the largest and most updated java test cases information on alibabacloud.com

Java Design Pattern Hundred cases-factory method mode

Java aggregation is implemented from the java.util.Collection interface, the interface's parent interface Iterable stipulates that all Java aggregation must provide a iterator() method to return a Iterator type of object:Java.lang.Iterable.javaPublic interface IterableArraylis is one of the collection implementation classes we use, and its iterator () method is implemented as follows:Java.util.ArrayList.ja

Several cases of JAVA value passing and reference passing

method finishes executing, the address value pointed to by A1 has changed. A1 's original address value is copy-copied, so it doesn't change the value of a.cases similar to string type1 Public classTest3 {2 3 Public Static voidMain (string[] args) {4Person p =NewPerson ("Xiaoming");5 Change (p);6 System.out.println (p.name);7 }8 Public Static voidChange (person p1) {9Person person =NewPerson ("Little Red");TenP1 =Person ; One System.out.println (p1.name); A } - } - classPers

Java Design Pattern Hundred cases-Simple Factory mode

Factory mode (Factory pattern) is one of the most common design patterns in Java. This type of design pattern belongs to the Create pattern, which provides a good way to create objects. In particular, there are modes such as simple factory, Factory mode (factory method), and abstract Factory mode (abstraction Factory).This article starts with the simple factory model.Example Imagine a simple need, you are making a drawing software that can draw rectan

Java meta Annotations, simple cases

{}@Interfacemyanno4{String value (); intA ()default1;} "Custom Annotation Cases"Annotation class1 Packagecom.xujingyang.annotation;2 3 ImportJava.lang.annotation.ElementType;4 Importjava.lang.annotation.Retention;5 ImportJava.lang.annotation.RetentionPolicy;6 ImportJava.lang.annotation.Target;7 8 //keep to run time9 @Retention (retentionpolicy.runtime)Ten //can only act on the method One @Target (Elementtype.method) A Public@InterfaceMyTest { -

GUI Programming Note (Java) 09:gui control text box can only enter numeric character cases

1. First, let's look at my needs, as follows:control text box can only enter numeric characters2. Source code: Packagecn.itcast_07;Importjava.awt.FlowLayout;ImportJava.awt.Frame;ImportJava.awt.Label;ImportJava.awt.TextField;ImportJava.awt.event.KeyAdapter;Importjava.awt.event.KeyEvent;ImportJava.awt.event.WindowAdapter;Importjava.awt.event.WindowEvent;/** If you enter a non-numeric character, the effect of your keyboard entry will be canceled. */ Public classFramedemo { Public Static voidMa

Java Basics Enhanced IO flow Note 50:io Stream practice copy multi-level folder cases

);Wuyi } the } - Private Static voidCopyFile (file srcfile, file newFile)throwsIOException { WuBufferedinputstream bis =NewBufferedinputstream (NewFileInputStream ( - srcfile)); AboutBufferedoutputstream BOS =NewBufferedoutputstream ( $ NewFileOutputStream (NewFile)); - byte[] Bys =New byte[1024]; - intLen = 0; - while(len = Bis.read (bys))! =-1) { ABos.write (bys, 0, Len); + } the bos.close (); - bis.close (); $ } the}

All cases that Java Script this points to

1. Direct call, point to GlobalConsole.log (this);2. Called in the normal function, pointing to the globalfunction fn () {Console.log (this);}FN ();3. Constructor normal call, point to Global (constructor is also normal function, can execute normally)function Student () {This.name= "Zhangsan";Console.log (this);}Student ();4. The constructor creates an instance object from the new call, pointing to the instance objectvar x=0;function Student (name,x) {This.name=name;This.x=x;Console.log (this.x)

Java Common 100 Cases

It is the true nature of the struggle to do a good deed to be held up by duty. --BalzacThe content of this lecture: 100 cases commonly used in JavaExample 1: Printing pyramidspublic class T {public static void main (string[] args) {int lay=10;for (int i=1;iResults: * *** ***** ******* ********* *********** ************* *************** ************ ************************Example 2: Print an empty pyramidpublic clas

Use cases for Java me-list controls

Destroyapp (Boolean arg0) throws Midletstatechangeexception {TODO auto-generated Method Stub}protected void Pauseapp () {TODO auto-generated Method Stub}protected void startApp () throws Midletstatechangeexception {TODO auto-generated Method StubImage[] Imagearray=null;if (firsttime){try {Image icon=image.createimage ("Images/icon.png");Imagearray=new Image[]{icon,icon,icon};} catch (IOException e) {TODO auto-generated Catch blockE.printstacktrace ();}}String[] stringarray={"Exclusive", "implic

Java single case and multiple cases

The function of a singleton is to control how the class is generated, without letting the outer class arbitrarily new objects1.car.javaImport Java.util.arraylist;import Java.util.list;public class Car {//privatized constructor to prevent the external class Newprivate Car () {}private static Car car = new car ();//single private static list  2.test.javapublic class Test {@org. junit.testpublic void Test () {

Java Several collection usage cases

The difference between Collection and collections.Collections is a Java.util class that contains a variety of static methods related to collection operations.Collection is a Java.util interface, which is the parent interface of various collection structures.Does the List, Set, and map inherit from the collection interface? List,set is map is notThe difference between ArrayList and vectors. Normal work priority use ArrayListI. Synchronization: vector is thread-safe, that is, synchronous, and Arra

Comma delimiter--the parsing method of the field with commas and other cases Java implementation

Recently in the processing of text strings, no row of data are separated by commas, each field value is usually enclosed in double quotation marks, but some field values also contain commas, and even some fields do not have double quotation marks, this is a bit troublesome to split upHere's a look at my solution, if anyone has a better way, welcome to join the discussion O (∩_∩) o~/*** Java string comma split parsing method * This is specifically desi

Migrating from Java and JSP programs in Windows Server to Linux server cases

1. It proves that Java program is run everywhere at once, and also proves the cross-platform feature of Java program, basically do not make great changes to run the program normally;2. The physical separation between the data layer and the business layer is done, and Windows is made a database server and Linux as a Web server;3. An error occurred: encoding UTF8 of the non-mapped characters, because the

Java Design Pattern Hundred cases-Singleton mode

for the first time, getInstance() SingleObjectHandler thus loading it, and naturally creating an LazyHandlerSingleObject instance, SingleObjectHandler by guaranteeing that the static instance is unique.EnumerationThis implementation has not been widely used, but this is the best way to implement a singleton pattern. It is more concise, automatically supports serialization mechanisms, and absolutely prevents multiple instantiations.This approach is advocated by effective

Java Fundamentals-Basic data type conversion cases

direct conversionIntLongFloatDoubleBoolean (itself True/false only two values, so no other type can be converted)Char (Char's particularity makes char unable to use other conversions)One can see the difference1. In addition to the other types of char can be converted from small to large, the view period source code is inherited, implemented the following ways? extendsimplementsHave inherited the number class. Which is the digital type.2.char different from other data types The reason is also h

Java Classic-Deadlock cases

Deadlock principle: Two threads waiting for each other to release the Sync MonitorExample program:1 Public classTestdeadlockImplementsRunnable {2 3 Public intFlag = 1;4 StaticObject O1 =NewObject (), O2 =NewObject ();5 6 Public voidrun () {7 if(Flag = = 1) {8 synchronized(O1) {9 Try {TenThread.Sleep (500); One}Catch(Exception e) { A e.printstacktrace (); - } - synchronized(O2) { theSystem.out.println ("1"); -

Use cases for Java threadlocal

ConnectionManager {STA Tic string drivername = "", static string url = "", static string user = "", static string password = "";p ublic static Connec tion getconnection () {try {return drivermanager.getconnection (URL, user, password);} catch (SQLException e) {//TODO auto- Generated catch Blocke.printstacktrace ();} return null;}} /** * * @author liuguangxin * */public class Userdao {//① use threadlocal to save connection variable//Because DAO pass-through is just a singleton in the system, so

Java Collections-Cases

1, ArrayList collection, contains rewrite:2. Vectors use enumerations to iterate through the collection3. List-specific iterators4. HashSet collection, storing custom data types, requiring overriding hashcode () and Equals () methods5. TreeSet Collection stores custom data types, overriding comparisonsComparable interface: Comparato method:Comparator interface:6, Collections Tool class:7. Traverse the Map collection:1.2.Java Collections-

Java test exercises, java Test

Java test exercises, java Test Multiple choice questions (50 questions in total, 1.5 points for each question, a total of 75 points. If multiple choice questions are incomplete or incorrect, no score is obtained .)1. The following are object-oriented features (C, D ). (Two items)A) Heavy LoadB) rewriteC) EncapsulationD

Some java test questions and self-made simulation server and client, java test questions

Some java test questions and self-made simulation server and client, java test questionsMedia 1, java environment variable: PATH :.; % JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin; CLASSPATH :.; % JAVA_HOME % \ jre \ lib \ rt. jar; % JAVA_HOME % \ lib \ dt. jar; % JAVA_HOME

Total Pages: 15 1 .... 9 10 11 12 13 .... 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.