总结
总体来说,如果你想转行从事程序员的工作,Java开发一定可以作为你的第一选择。但是不管你选择什么编程语言,提升自己的硬件实力才是拿高薪的唯一手段。
如果你以这份学习路线来学习,你会有一个比较系统化的知识网络,也不至于把知识学习得很零散。我个人是完全不建议刚开始就看《Java编程思想》、《Java核心技术》这些书籍,看完你肯定会放弃学习。建议可以看一些视频来学习,当自己能上手再买这些书看又是非常有收获的事了。
=================================================================
public class dishizhang {
public static void main(String[] args) {
// TODO Auto-generated method stub
Time time1 = new Time();
Time time2 = new Time(555550000);
System.out.printf(“%dh/%dm/%ds\n”, time1.getHour(), time1.getMinute(), time1.getSecond());
System.out.printf(“%dh/%dm/%ds\n”, time2.getHour(), time2.getMinute(), time2.getSecond());
}
}
class Time {
private int hour;
private int minute;
private int second;
public Time() {
long t = System.currentTimeMillis();
long seconds = t / 1000;
second = (int) seconds % 60;
seconds /= 60;
minute = (int) seconds % 60;
seconds /= 60;
hour = (int) seconds % 24;
}
public Time(long t) {
long seconds = t / 1000;
second = (int) seconds % 60;
seconds /= 60;
minute = (int) seconds % 60;
seconds /= 60;
hour = (int) seconds % 24;
}
int getHour() {
return hour;
}
int getMinute() {
return minute;
}
int getSecond() {
return second;
}
public void setTime(long elapseTime) {
long seconds = elapseTime / 1000;
second = (int) seconds % 60;
seconds /= 60;
minute = (int) seconds % 60;
seconds /= 60;
hour = (int) seconds % 24;
}
}
=================================================================
前面课文有提及,添加一个方法就行。
public class BMI {
private String name;
private int age;
private double weight;
private double height;
public static final double KILOGRAMS_PER_POUND = 0.45359237;
public static final double METERS_PER_INCH = 0.0254;
public BMI(String name,int age,double weight,double height){
this.name = name;
this.weight = weight;
this.height = height;
this.age = age;
}
public BMI(String name,double weight,double height){
this(name,20,weight,height);
}
public double getBMI(){
double bmi = weight * KILOGRAMS_PER_POUND / ((height * METERS_PER_INCH) * (height * METERS_PER_INCH));
return Math.round(bmi * 100) / 100.0;
}
public String getStatus(){
double bmi = getBMI();
if (bmi < 18.5)
return “Underweight”;
else if (bmi < 25)
return “Normal”;
else if (bmi < 30)
return “Overweight”;
else
return “Obese”;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
public double getWeight(){
return weight;
}
public double getHeight() {
return height;
}
public BMI(String name,int age,double weight,double feet,double inches){
this.name = name;
this.age = age;
this.weight = weight;
this.height = feet * 12 + inches;
}
}
=================================================================
import java.util.Scanner;
public class dishizhang {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("Enter n1: ");
MyInteger n1 = new MyInteger(input.nextInt());
System.out.println(“Is n1 a even?” + ‘\t’ + n1.isEven());
System.out.println(“Is n1 a prime?” + ‘\t’ + n1.isPrime());
System.out.println(“Is n1 a prime2?” + ‘\t’ + MyInteger.isPrime(n1));
System.out.println(“Is n1 a odd?” + ‘\t’ + n1.isOdd());
System.out.println(“Is n1 a odd2?” + ‘\t’ + MyInteger.isOdd(n1));
System.out.print("Enter n2: ");
MyInteger n2 = new MyInteger(input.nextInt());
System.out.println(“Are n1 and n2 equal?” + ‘\t’ + n1.equals(n2));
System.out.println(“Are n1 and 5 equal?” + ‘\t’ + n1.equals(5));
}
}
class MyInteger {
private int value;
public MyInteger(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static boolean isEven(int value) {
if (value % 2 == 0)
return true;
else
return false;
}
public boolean isEven() {
return isEven(value);
}
public boolean isOdd() {
return isOdd(value);
}
public boolean isOdd(int value) {
if (value % 2 != 0)
return true;
else
return false;
}
public boolean isPrime() {
return isPrime(value);
}
public static boolean isPrime(int value) {
for (int i = 2; i < value - 1; i++)
if (value % i == 0)
return false;
return true;
}
public static boolean isEven(MyInteger m) {
if (m.getValue() % 2 == 0)
return true;
else
return false;
}
public static boolean isOdd(MyInteger m) {
if (m.getValue() % 2 != 0)
return true;
else
return false;
}
public static boolean isPrime(MyInteger m) {
for (int i = 2; i < m.getValue() - 1; i++) {
if (m.getValue() % 2 == 0)
return false;
}
return true;
}
public boolean equals(int value) {
if (this.value == value)
return true;
else
return false;
}
public boolean equals(MyInteger m) {
if (this.value == m.getValue())
return true;
else
return false;
}
}
=================================================================
public class dishizhang {
public static void main(String[] args) {
// TODO Auto-generated method stub
MyPoint p1 = new MyPoint(0,0);
MyPoint p2 = new MyPoint(10,30.5);
System.out.println("The distance is "+p1.distance(p2));
}
}
class MyPoint{
private double x;
private double y;
MyPoint(){
this.x = 0.0;
this.y = 0.0;
}
public MyPoint(double x,double y){
this.x = x;
this.y = y;
}
public double distance(double x,double y){
double s;
s = Math.sqrt((this.x - x)(this.x - x)+(this.y - y)(this.y - y));
return s;
}
public double distance(MyPoint mypoint){
double s;
s = Math.sqrt((this.x - mypoint.getX()) * (this.x - mypoint.getX())+(this.y - mypoint.getY()) * (this.y - mypoint.getY()));
return s;
}
public double getX(){
return x;
}
public double getY(){
return y;
}
}
=================================================================
import java.util.Arrays;
import java.util.Scanner;
public class dishizhang {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.print(“Please input a integer :”);
Scanner input = new Scanner(System.in);
int integer=input.nextInt();
StackOfIntegers stackOfIntegers = new StackOfIntegers(integer);
int[] i=stackOfIntegers.Prime();
System.out.print("All the prime factors of the “+integer+ " are :”);
System.out.print(Arrays.toString(i));
}
}
class StackOfIntegers{
private int integer;
public StackOfIntegers(int integer) {
this.integer = integer;
}
private static int k = 0;
private static int l = 0;
public int[] GetPrime() {
int[] getPrime = new int[this.integer];
boolean isPrime = true;
for (int i = 2; i < this.integer; i++) {
for (int j = 2; j < i; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
最后
笔者已经把面试题和答案整理成了面试专题文档
teger];
boolean isPrime = true;
for (int i = 2; i < this.integer; i++) {
for (int j = 2; j < i; j++) {
if (i % j == 0) {
isPrime = false;
break;
}
}
if (isPrime) {
最后
笔者已经把面试题和答案整理成了面试专题文档
[外链图片转存中…(img-kDWlSDym-1715572455374)]
[外链图片转存中…(img-ARVqhRSD-1715572455375)]
[外链图片转存中…(img-Abc6vqA6-1715572455375)]
[外链图片转存中…(img-d8QMHwVa-1715572455376)]
[外链图片转存中…(img-pXuF7Cns-1715572455376)]
[外链图片转存中…(img-8L4BsUUZ-1715572455377)]