corejava_语法

对于corejava阶段,无论是新手还是大牛,都需要了解的几个点?

1)面向对象的三大特性,四大原则

封装,继承,多态

各司其职,可复用性,可拓展性,弱耦合性

2)java来源于生活,java中的对象等都可以使用生活中的各种例子来佐证,主要是需要看你平时的生活阅历是否丰富。

3)编程始终需要把握的是:高内聚,低耦合。

4)接口铸就java(后面有讲解)


以上几项是我在学习corejava的时候,总结的几点,用于与大家相互交流思想和心得。


我的博客从这里开始对java,会进行一个阶段性,细致性的论述(阶段:corejava->web->struts2->mybatis->spring->springMvc 以及html/css->js->jquery->ajax->easyui)

1)int [] a = new int[3]{1,2,3};     error!

      int []a = new int[]{1,2,3};         true

2)冒泡排序

[java]  view plain  copy
  1. public class BubbleSort{
  2. public static void main(String[] args){
  3. int [] arr = {5,1,2,3,4};
  4. BubbleSort(arr);
  5. printResult(arr);
  1. }
  2. //冒泡排序算法
  3. public static void BubbleSort(int[] arr){
  4. //控制趟数
  5. for(int i=0;i<arr.llength-1;i++){
  6. //控制每趟比较的次数
  7. for(int j=0;j<arr.length-1-i;j++){
  8. if(arr[j] > arr[j+1]){
  9. int temp=arr[j];
  10. arr[j]=arr[j+1];
  11. arr[j+1]=temp;
  12. }
  13. }
  14. }
  15. }
  16. //输出语句
  17. public static void printResult(int []arr){
  18. for(int i=0;i<arr.length;i++){
  19. System.out.print(arr[i]+" ");
  20. }
  21. }
  1. }

2)选择排序

[java]  view plain  copy
  1. public class BubbleSort{
  2. public static void main(String[] args){
  3. int [] arr = {6,4,5,3,2,1};
  4. SelectSort(arr);
  5. printResult(arr);
  1. }
  2. //选择排序算法
  3. public static void SelectSort(int[] arr){
  4. //控制趟数
  5. for(int i=0;i<arr.llength-1;i++){
  6. //控制每趟比较的次数
  7. for(int j=0;j<arr.length-1-i;j++){
  8. if(arr[j] > arr[j+1]){
  9. int temp=arr[j];
  10. arr[j]=arr[j+1];
  11. arr[j+1]=temp;
  12. }
  13. }
  14. }
  15. }
  16. //输出语句
  17. public static void printResult(int []arr){
  18. for(int i=0;i<arr.length;i++){
  19. System.out.print(arr[i]+" ");
  20. }
  21. }
  1. }

4)类的简单概述

5)成员方法可以直接使用成员变量和局部变量

6)实参和形参的理解


7)写一个在输入时候的遇到的小错误


8)9*9乘法表

[java]  view plain  copy
  1. public class NineToNine{
  2. public static void main(String[] args){
  3. NineToNineMethod();
  1. }
  2. //9*9
  3. public static void NineToNineMethod(){
  4. //控制趟数
  5. for(int i=1;i<10;i++){
  6. //控制每趟比较的次数
  7. for(int j=1;j<=i;j++){
  8. Sysout.out.print(i+"*"+j+"="i*j+" ");
  9. }
  10. System.out.println(" ");
  11. }
  12. System.out.println("\t");
  13. }
  1. }
10)求阶乘的两种算法

首先对递归思想进行一下分析

第一种递归算法

[java]  view plain  copy
  1. public class jiecheng{
  2. public static void main(String [] args){
  3. int result = TwoMethod(3);
  4. System.out.println(result);
  5. }
  6. //递归求值
  7. public static int TwoMethod(int number){
  8. if(number==1){
  9. return 1;
  10. }else{
  11. return number*TwoMethod(number-1);
  12. }
  13. }
  1. }

第二种循环算法

[java]  view plain  copy
  1. public class jiecheng{
  2. public static void main(){
  3. double result = jiechengMethod(4);
  4. System.out.println(result);
  5. }
  6. //循环求阶乘
  7. public static double jiechengeMethod(int input){
  8. double num = 1;
  9. for(int i=1;i<=input;i++){
  10. number *=i;
  11. }
  12. return num;
  13. }
  1. }
11)重载(overload)

12)构造方法(允许重载)

          

13)数据类型

          byte   short   int   long   float   double   char   boolean

           1B       2B      4B   8B      4B        8B         2B        1B

14)自动类型提升

          

15)字符创相加问题

          

16)局部变量

          ①先赋值,后使用

          ②作用域从定义位置开始,到代码块结束截止

          ③重合范围内,不允许两个局部变量命名冲突

17)函数特点

          ①避免冗余

          ②可维护性提高

          ③重用性提高

          ④灵活性提高

18)局部变量和实例变量(成员变量)

           

19)编程思想及其重要性

           高内聚,低耦合

           台式电脑:主机损坏,整个淘汰

          笔记本电脑:主机内聚,接口连接,可任意更换配件

20)为什么实例变量不用赋初始值?

          

21)面向对象思想:

          各司其职          弱耦合性          可重用性          可拓展性

22)成员变量不可以先定义后赋值

          int age;

          age=10;                          error!

23)基本变量和引用变量的区别?

            

24)this关键字(当前对象)

          

25)堆和栈的认识:

          



          以上内容,纯属手工,难免有漏洞之处,希望能和大家互相交流,共同进步!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值