摘要:1 2 3 import java.io.File; 4 import java.io.FileInputStream; 5 import java.io.FileOutputStream; 6 import java.io.InputStream; 7 import java.io.Outp...
阅读全文
摘要:1 public class TestMode { 2 3 public static void main(String[] args) { 4 int x = -3; 5 int y = -10; 6 System.out.println...
阅读全文
摘要:1 public class Question1 { 2 3 public static void main(String[] args) { 4 String dir=""; 5 if(args.length!=1) 6 { 7 ...
阅读全文
摘要:1 public boolean accountBalance(double accountBalance){ 2 3 String regex1 ="[1-9]+\\d+[.][0]"; 4 String regex2 ="[0][.]\\d+"; 5 ...
阅读全文
摘要:1 public class SwingTest123 extends JFrame implements ActionListener { 2 3 JRadioButton boy, girl; 4 JLabel mess; 5 ButtonGroup group; 6...
阅读全文
摘要:1 class Person1 implements Comparable { 2 private Float height; 3 private String name; 4 5 Person1(float height) 6 { 7 t...
阅读全文
摘要:1 import java.util.Collections; 2 import java.util.Comparator; 3 import java.util.LinkedList; 4 5 class Person{ 6 private float height; 7 pr...
阅读全文
摘要:1 package com.cn.test20; 2 3 import java.sql.Connection; 4 import java.sql.DriverManager; 5 import java.sql.ResultSet; 6 import java.sql.SQLExceptio...
阅读全文
摘要:手机号: 1 public boolean customerPhonenumber(String customerPhonenumber){ 2 boolean IsRight=false; 3 // \\+\\d{13}|\\d{11} 4 String re...
阅读全文
摘要:1 package Test8_19; 2 3 import java.util.Scanner; 4 5 public class CheckDate { 6 public static void main(String args[]) { 7 Chec...
阅读全文
摘要:无线程同步:存储数据: 1 public class Storage { 2 int data; 3 4 public int getData() { 5 return data; 6 } 7 8 public void setData(int ...
阅读全文
摘要:1 package Aug14.IO; 2 3 import java.io.*; 4 5 public class TestIO2 { 6 7 public static void main(String[] args) { 8 File file = new Fi...
阅读全文
摘要:Create a class Employee which extends from a class Person. The attributes of Person class are name, address, age. The attributes of the Employee clas...
阅读全文
摘要:1 package Aug14.IO; 2 3 import java.io.*; 4 import java.util.*; 5 import java.util.Map.Entry; 6 7 public class TestCurrentAccount { 8 9 ...
阅读全文
摘要:1 package Aug14.IO; 2 3 4 5 import java.io.*; 6 import java.util.*; 7 import java.util.Map.Entry; 8 9 class Student implements Serializa...
阅读全文
摘要:1 Object[] key_arr = hashmap.keySet().toArray(); 2 Arrays.sort(key_arr); 3 for (Object key : key_arr) { 4 Object value = hashmap.get(key); ...
阅读全文
摘要:概念: java中单例模式是一种常见的设计模式,单例模式分三种:懒汉式单例、饿汉式单例、登记式单例三种。 单例模式有一下特点: 1、单例类只能有一个实例。 2、单例类必须自己自己创建自己的唯一实例。 3、单例类必须给所有其他对象提供这一实例。 单例模式确保某个类只有一个实例,而且自行实例...
阅读全文
摘要:1)java集合框架的层次结构2)使用Collection接口定义的公用方法对集合和线性表操作3)使用Iterator接口遍历集合4)使用JDK的增强for循环替代迭代Iterator进行集合遍历5)熟悉Set接口,了解何时及如何使用HashSet,LinkedHashSet或TreeHashSet...
阅读全文
摘要:1 package Aug11.Collection; 2 3 import java.util.HashSet; 4 import java.util.LinkedList; 5 import java.util.Set; 6 7 public class Test { 8 9 p...
阅读全文
摘要:Implement HashSet to store ‘n’ records of students ( Name, Percentage). Write a menu driven program to :1. Add student2. Display details of all studen...
阅读全文
摘要:1 public class AgeBelow18Exception extends RuntimeException {2 /*public String getMessage() {3 return "Please Call Users Above 18 Years";4...
阅读全文
摘要:public Test() throws RepletException { try { System.out.println("Test this Project!") } catch (Exception e) { throw new Exception(e...
阅读全文
摘要:异常指不期而至的各种状况,如:文件找不到、网络连接失败、非法参数等。异常是一个事件,它发生在程序运行期间,干扰了正常的指令流程。Java通 过API中Throwable类的众多子类描述各种不同的异常。因而,Java异常都是对象,是Throwable子类的实例,描述了出现在一段编码中的 错误条件。当条...
阅读全文
摘要:1 package com.intel.aug6; 2 3 import java.util.InputMismatchException; 4 import java.util.Scanner; 5 6 public class TestException2 { 7 8 publi...
阅读全文
摘要:1、Java取余操作: 结果符号:与左操作数相同;-64%-6 = -4 操作数: 两个都是整型:int xint yx%y, 如果y=0, 则抛出arithmeticException异常: 操作数中有浮点型:int x double y; 取余操作的过程,不断用x减去y,直到结果小于y即可。 如...
阅读全文
摘要:Create an interface called Sortable in a package called sortPack. It should have one method compare which takes an Object as a parameter and returns a...
阅读全文
摘要:1) I love you not because of who you are, but because of who I am when I am with you. 我爱你,不是因为你是一个怎样的人,而是因为我喜欢与你在一起时的感觉。 2) No man or woman is wo...
阅读全文