java exercise book

Alibabacloud.com offers a wide variety of articles about java exercise book, easily find your java exercise book information here online.

Java Collection Framework Exercises: Write a book class that has at least the name and price two properties. The class to implement the comparable interface, in the interface of the CompareTo () method .....

-generated method stubsarraylistBook B1=new Book ("Basic Java Tutorial", 29f);Book B2=new Book ("Database Technology", 29f);Book B3=new Book ("Basic C + + tutorial", 28f);List.add (B1);List.add (B2);List.add (B3);IteratorBook

A view of the book of Java from Getting started to mastering (second edition)

I seriously probation the book today, first of all, according to the author's habit of Reading, like to first look at the front part. The author puts a roadmap to learning Java in the preface, which is a relatively standard learning process. But why in the programming advanced there put a design pattern, and then next is the abstract class and interface, package and access permissions (this name and

Java Basic Tutorial Full version of the electronic version of the book is officially released, you are welcome to download free

until now, the Java Series tutorial has been updated. Content covered: Javase basic knowledge points, UML modeling, unit testing and so on. I want to be able to help a friend who wants to learn the Java language. in the process of writing, there will inevitably be some mistakes, I hope you can make a lot of suggestions. Because this book is from the author Csdn b

Java (Multi-state exercise instanceof)

/* Title: (polymorphic, instanceof) has the following code class animal{private String name;//1}class Dog extends Animal{//2}class Cat extends animal{// 3}public class Testanimal{public static void Main (String args[]) {animal[] as = new Animal[]{new Dog ("Pluto"), New Cat ("Tom" ), New Dog ("Snoopy"), New Cat ("Garfield")};D og[] dogs = Getalldog (AS), for (int i = 0; i  Java (Multi-state exercise instance

Algorithmic note _093: Blue Bridge cup exercise problem s4:interesting Numbers enhanced (Java)

paper:The following code results run as 90 points, the code is for reference only, at the end of the article 1 of the code runs the result of 100 points, you can refer to OH.The specific code is as follows:ImportJava.util.Scanner; Public classMain { Public Final Static Longp = 1000000007L; //To find the value of the B-order residual p of a Public LongGetpowmod (LongALongb) {Longtemp = A, result = 1; while(b! = 0) { if((b 1) = = 1) Result= result * Temp%p; Temp= Temp * Temp%p; b

Algorithm note _084: Blue Bridge Cup exercise 11-1 Implementing the STRCMP function (Java)

Directory 1 Problem Description 2 Solutions 1 problem description Problem DescriptionImplement a function that compares the size of a string, that is, implement the STRCMP function. function: int mystrcmp (char *s1,char *s2) compares strings S1 and S2 in ASCII order. If the S1 is equal to S2 returns 0,S1>S2 returns 1,S1"A" "A" > "a""Computer" > "Compare ""Hello" Sample Outputdata size and conventionsstring length 2 Solutions The specific code is as follows:ImportJava.util.Scanner; P

Java series: My first spring AOP exercise

" /> Aop:afterPointcut-ref= "Dbmethod"Method= "Logafter" /> Aop:aspect> Aop:config> BeanID= "Dbinterface"class= "com. Dbinterface.dbinterface "Autowire= "Bytype"/> BeanID= "Setuptable"class= "com. DBINTERFACEFORPG.SETUPTABLEFORPG "/> BeanID= "Logger"class= "com. PecTrend.util.LoggerWithMethodName "/> Beans> Public classApp { Public Static voidMain (string[] args) {ApplicationContext ctx=NewClasspathxmlapplicationcontext ("Pectrend.xml"); Dbinterfa

Java after-school Exercise 3

;Import Java.util.Scanner;public class Sgg {public static void Main (string[] args) {//TODO auto-generated method stubScanner in = new Scanner (system.in);System.out.print ("Please enter N:");int n = in.nextint ();System.out.print ("Please enter K:");int k = In.nextint ();SYSTEM.OUT.PRINTLN ("Combined number result is:" +sgg (n,k));In.close ();}public static int Sgg (int m,int N){if (mreturn 0;if (m==n)return 1;if (n==1)return m;Return Sgg (m-1,n) +sgg (m-1,n-1);}}Output Result:After-school assi

Java Getting started the third season sort exercise

Package Imooc_collection_map_demo;Import java.util.ArrayList;Import java.util.Collections;Import java.util.List;Import Java.util.Random;/**Practice* 1, after creating the list* 2, a random integer with a length of 10 or less for each string* 3, each character of each string is a randomly generated character, the character can be repeated* 4, each random string is not repeatable*/public void Testprotice () {ListRandom random2=new random ();Char[]temp=null;int length;int casebyte;for (int i=0;ido{

Java Exception Handling Exercise 2

Set up the exception package, set up a bank class, the class has a variable double balance represents a deposit, the bank class construction method can increase the deposit, the bank class has the withdrawal method withdrawal (double damount), when the amount of withdrawals is greater than the deposit , throws the insufficientfundsexception, the withdrawal amount is negative, throws Nagativefundsexception, if the new bank (100), represents the deposit bank 100 yuan, when uses the method withdraw

Java class and Object basics Exercise 1, student information, 2 ways

The first method; object initialization. PackageCom.hanqi;Importjava.lang.*; Public classstudent{intXuehao; String name; intAge ; Student (intXuehao,string name,intAge ) { This. xuehao=Xuehao; This. name=name; This. age=Age ; } voidoutput () {System.out.println ("School Number:" +xuehao+ "" + "Name:" +name+ "" + "Age:" +Age ); } Public Static voidMain (string[] args) {student S1=NewStudent (44, "Xiaoming", 21); S1.output (); }}In the second method, you create multiple

Java exception Exercise: Ask the user to enter a number, to capture and handle the user input error exception, to prompt the user

PackageCom.yichang;ImportJava.util.*; Public classTest2 { Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); System.out.println ("Please enter a number:"); Try{ intA =Sc.nextint (); System.out.println ("The input is:" +a); } Catch(Exception ex) {ex.printstacktrace (); System.out.println ("Wrong type of input" +ex.getmessage ()); } }}Java exception Exercise: A

Java Threading Test Tour little Exercise

PackageCom.hanqi.xc;ImportJava.util.Random; Public classLvyouextendsThread {@Override Public voidrun () { for(inti=0;i) {System.out.println ("Thread test" + "" +Thread.CurrentThread (). GetName ()); Try{Random R1=NewRandom (); intA = R1.nextint (1000); Thread.Sleep (a); } Catch(interruptedexception e) {//TODO Auto-generated catch blockE.printstacktrace (); } } } } PackageCom.hanqi.xc; Public classCS { Public Static voidMain (string[] args) {lvy

JAVA exercise-calculate the circumference rate π and circumference rate π for given precision

JAVA exercise-calculate the circumference rate π and circumference rate π for given precision Returns an approximate value of the circumference rate π with a given precision. Given formula: π/4 = 1-1/3 + 1/5-1/7 + 1/9 -... 1 public static void main (String [] args) {2 System. out. println ("Enter the precision of π (the number of digits after the decimal point)"); 3 bytes input = new bytes (System. in);

Java Fundamentals Exercise given a positive integer m, the number of bits of m, each digit is printed, and then the numbers are printed in reverse order.

Requirements:m is defined as a property of the class, the constructor must be defined as m assignment, and when m is greater than 99999 , the output error message " the number is too large"and is no longer executed. Public classT {Private intm; PublicTintm) {Super(); This. m =m; } Public intGetm () {returnm; } Public voidSetm (intm) { This. m =m; } Public voidM () {if(m>99999) {System.out.println ("The number is too large"); } Else{String str=m+ ""; System.out.println ("A t

Java Algorithm Little knowledge Exercise

Occasionally opened the previous exercises, unconscious and want to knock once again, although some ideas are still so old-fashioned, but after all, is also a consolidation of knowledge.First, the title: There are 1, 2, 3, 44 numbers, can make up how many different and no duplicate number of three digits? How much are they?The specific idea is simple, is to take out a number, with the other three of any two non-repeating groups, and finally add up,/*** Title: There are 1, 2, 3, 44 numbers, can m

Java Loop Exercise: Demo Registration and Login

congratulations! Login Successful!Welcome to register Login Simulation system Please enter the user name: Yeleven Please enter the password: 123456 user name: Yeleven can I use the current username and password to register? Y is n-No y congratulations! Registration Successful! Please login! Please enter the user name: Yeleven Please enter the password: 654321 input error, please continue to enter. You have 2 chances. Please enter your username: Yelevena Please enter your password: 123456 input

JAVA exercise questions,

JAVA exercise questions, packagecn.person.www; public class person { public int id; public String name; public int age; public String city; public String introduce() { return "I am" + id + "No., called" + name + ", This year" + age + "Aged, from" + city ; } public person( int id,String name, int age,String city) { this .id=id; // This keyword indicates the current object. It indicates a call of th

Java Basics Exercise 20

Import Java.util.Scanner;public class Twentieth {/* A company using a public telephone to pass data, the data is a four-bit integer, is encrypted during delivery, encryption rules are as follows: Each digit is added 5, and then divided by the remainder of 10 instead of the number, then the first and fourth exchange, the second and third exchange. */public static void Main (string[] args) {Scanner input=new Scanner (system.in);System.out.println ("Please enter the number to encrypt:");int A=input

Java Basics Exercise 13

Import Java.util.Scanner;public class Thirtheen {/* Enter a certain month of the year, and determine the day of the year? */public static void Main (string[] args) {Scanner input=new Scanner (system.in);int sum,i;System.out.print ("Please enter the Year:");int A=input.nextint ();System.out.print ("\ n");System.out.print ("Please enter the month:");int B=input.nextint ();System.out.print ("\ n");System.out.print ("Please enter the day:");int C=input.nextint ();System.out.print ("\ n");if (a%4==0a

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