public String toString() {
return "Triangle: side1 = " + s1 + " side2 = " + s2 + " side3 = " + s3;
}
}
11.2
=================================================================
package dishiyizhang;
public class dishiyizhang{
public static void main(String[] args) {
Student s = new Student(Student.ONE,“老刘”,“上海”,“123456789”,“13456@email”);
Employee e = new Employee(“程序员”,2300.0,“老张”,“北京”,“123456789”,“145662@email”);
Faculty f = new Faculty(“程序员2”,2300.0,“time”,“grade”,“老李”,“北京”,“123456789”,“145662@email”);
Staff sta = new Staff(“程序员3”,2300.0,“post”,“老周”,“北京”,“123456789”,“145662@email”);
System.out.println(s.toString());
System.out.println(e.toString());
System.out.println(f.toString());
System.out.println(sta.toString());
}
}
class Person {
private String name;
private String address;
private String number;
private String Email;
protected Person() {
}
protected Person(String name, String address, String number, String Email) {
this.name = name;
this.address = address;
this.number = number;
this.Email = Email;
}
protected String getName() {
return name;
}
protected void setName(String name) {
this.name = name;
}
protected String getAddress() {
return address;
}
protected void setAddress(String address) {
this.address = address;
}
protected String getNumber() {
return number;
}
protected void setNumber(String number) {
this.number = number;
}
protected String getEmail() {
return Email;
}
protected void setEmail(String Email) {
this.Email = Email;
}
@Override
public String toString() {
return “ObejectByPerson” + “Name:” + getName();
}
}
class Student extends Person {
public final static String ONE = “Freshman”;
public final static String TWO = “Sophomore”;
public final static String THREE = “Junior”;
public final static String FOUR = “Senior”;
private String StudentState;
public Student() {
StudentState = ONE;
}
public Student(String StudentState, String name, String address, String number, String Email) {
super(name, address, number, Email);
this.StudentState = StudentState;
}
public String getStudentState() {
return StudentState;
}
public void setStudentState(String StudentState) {
this.StudentState = StudentState;
}
public String toStringOfAllInforation() {
return “Student is inforation:Grade:” + getStudentState() + “\tName:” + getName() + “\tAddress:” + getAddress()
}
@Override
public String toString() {
return “ObjectByStudent–>” + “Name:” + getName();
}
}
class Employee extends Person {
private String Office;
private double salary;
protected Employee() {
}
protected Employee(String Office, double salary, String name, String address, String number, String Email) {
super(name, address, number, Email);
this.Office = Office;
this.salary = salary;
}
protected String getOffice() {
return Office;
}
protected void setOffice(String Office) {
this.Office = Office;
}
protected double getSalary() {
return salary;
}
protected void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return “ObjectByEmployee–>” + “Name:” + getName();
}
}
class Faculty extends Employee {
private String OfficeTime;
private String PostGrade;
public Faculty() {
}
public Faculty(String Office, double salary, String OfficeTime, String PostGrade, String name, String address,
String number, String Email) {
super(Office, salary, name, address, number, Email);
this.OfficeTime = OfficeTime;
this.PostGrade = PostGrade;
}
public String getOfficeTime() {
return OfficeTime;
}
public void setOfficeTime(String OfficeTime) {
this.OfficeTime = OfficeTime;
}
public String getPostGrade() {
return PostGrade;
}
public void setPostGrade(String PostGrade) {
this.PostGrade = PostGrade;
}
public String toStringOfAllInforation() {
return “Faculty is inforation:PostGrade:” + getPostGrade() + “\tOfficeTime:” + getOfficeTime() + “\tSalary:”
getSalary() + “Office:” + getOffice() + “\tName:” + getName() + “\tAddress:” + getAddress()
“\tNumber:” + getNumber() + “\tEmail:” + getEmail();
}
@Override
public String toString() {
return “ObjectByFaculty–>” + “Name:” + getName();
}
}
class Staff extends Employee {
private String Post;
public Staff() {
}
public Staff(String Office, double salary, String Post, String name, String address, String number, String Email) {
super(Office, salary, name, address, number, Email);
this.Post = Post;
}
public String getPost() {
return Post;
}
public void setPost(String Post) {
this.Post = Post;
}
public String toStringOfAllInforation() {
return “Staff is inforation:Post:” + getPost() + “\tSalary:” + getSalary() + “Office:” + getOffice() + “\tName:”
}
@Override
public String toString() {
return “ObjectByStaff–>” + “Name:” + getName();
}
}
11.3
=================================================================
import java.util.Date;
public class dishiyizhang {
public static void main(String[] args) {
Account a = new Account(1, 2000);
CheckingAccount c = new CheckingAccount(114, 514, 1919);
Saving_Account s = new Saving_Account();
System.out.println(a.toString() + “\n” + c.toString() + “\n” + s.toString());
}
}
class Account {
private int id;
private double balance;
private double Rate;
private Date dateCreated;
public Account() {
id = 0;
balance = 0;
Rate = 0;
dateCreated = new Date();
}
public Account(int i, double b) {
id = i;
balance = b;
Rate = 0;
dateCreated = new Date();
}
public int getId() {
return id;
}
public void setId(int j) {
id = j;
}
public double getBalance() {
return balance;
}
public void setBalance(double j) {
balance = j;
}
public double getAnnualInterestRate() {
return Rate;
}
public void setAnnualInterestRate(double j) {
Rate = j;
}
public Date getDateCreated() {
return dateCreated;
}
public double getMonthlyInterestRate() {
return Rate / 12;
}
public double getMonthlyInterest() {
return Rate / 12 * balance;
}
public void withDraw(double m) {
balance -= m;
}
public void deposit(double m) {
balance += m;
}
}
class CheckingAccount extends Account {
private double overDraw;
public CheckingAccount() {
super();
}
public CheckingAccount(int i, double b, double o) {
super(i, b);
overDraw = o;
}
}
class Saving_Account extends Account {
//直接继承Account
}
11.4
=================================================================
import java.util.ArrayList;
import java.util.Scanner;
public class dishiyizhang {
public static void main(String[] args) {
System.out.print("Enter numbers (0 finished): ");
Scanner input = new Scanner(System.in);
ArrayList list = new ArrayList();
int n = input.nextInt();
while (n != 0) {
list.add(n);
n = input.nextInt();
}
System.out.println("The maximum is " + max(list));
}
public static Integer max(ArrayList list) {
if (list == null || list.size() == 0)
return null;
else
return java.util.Collections.max(list);
}
}
11.5
=================================================================
清单10-6.,,,,,前面的课程清单都找不到。。。看题目挺简单的,就是换成ArrayList来存储。
11.6
=================================================================
因为之前circle等的类都删除了,这里就写了一个Date对象,想要返回其他的再去看看前面课程吧。
import java.util.ArrayList;
import java.util.Date;
public class dishiyizhang {
public static void main(String[] args) {
ArrayList list = new ArrayList<>();
Date d = new Date();
list.add(d);
for(Object o: list)
System.out.println(o.toString());
}
}
11.7
=================================================================
import java.util.ArrayList;
public class dishiyizhang {
public static void main(String[] args) {
ArrayList list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.add(4);
shuffle(list);
System.out.println(list.toString());
}
public static void shuffle(ArrayList list){
java.util.Collections.shuffle(list);
}
}
11.8
=================================================================
import java.util.ArrayList;
其实关于Kafka,能问的问题实在是太多了,扒了几天,最终筛选出44问:基础篇17问、进阶篇15问、高级篇12问,个个直戳痛点,不知道如果你不着急看答案,又能答出几个呢?
若是对Kafka的知识还回忆不起来,不妨先看我手绘的知识总结脑图(xmind不能上传,文章里用的是图片版)进行整体架构的梳理
梳理了知识,刷完了面试,如若你还想进一步的深入学习解读kafka以及源码,那么接下来的这份《手写“kafka”》将会是个不错的选择。
Kafka入门
为什么选择Kafka
Kafka的安装、管理和配置
Kafka的集群
第一个Kafka程序
Kafka的生产者
Kafka的消费者
深入理解Kafka
可靠的数据传递
Spring和Kafka的整合
SpringBoot和Kafka的整合
Kafka实战之削峰填谷
数据管道和流式处理(了解即可)
shuffle(list);
System.out.println(list.toString());
}
public static void shuffle(ArrayList list){
java.util.Collections.shuffle(list);
}
}
11.8
=================================================================
import java.util.ArrayList;
[外链图片转存中…(img-ctvTvKfd-1719274970206)]
其实关于Kafka,能问的问题实在是太多了,扒了几天,最终筛选出44问:基础篇17问、进阶篇15问、高级篇12问,个个直戳痛点,不知道如果你不着急看答案,又能答出几个呢?
若是对Kafka的知识还回忆不起来,不妨先看我手绘的知识总结脑图(xmind不能上传,文章里用的是图片版)进行整体架构的梳理
梳理了知识,刷完了面试,如若你还想进一步的深入学习解读kafka以及源码,那么接下来的这份《手写“kafka”》将会是个不错的选择。
Kafka入门
为什么选择Kafka
Kafka的安装、管理和配置
Kafka的集群
第一个Kafka程序
Kafka的生产者
Kafka的消费者
深入理解Kafka
可靠的数据传递
Spring和Kafka的整合
SpringBoot和Kafka的整合
Kafka实战之削峰填谷
数据管道和流式处理(了解即可)
[外链图片转存中…(img-FLIILVoU-1719274970207)]
[外链图片转存中…(img-JftUdbaJ-1719274970207)]