Storm

superStorm


  • 首页

  • 关于

  • 标签

  • 分类

  • 归档

  • 公益404

  • 搜索

spring boot 学习笔记(一)

发表于 2019-03-01 | 分类于 java |
字数统计: 1k | 阅读时长 ≈ 4

  使用IntelliJ IDEA一键初始化一个web应用
在打开新建项目后选择spring initializr,然后next

阅读全文 »

kotlin学习(五)-高阶函数

发表于 2019-02-14 | 分类于 kotlin |
字数统计: 254 | 阅读时长 ≈ 1

  kotlin的高阶函数是指将函数作为参数或返回值的函数

  • 将函数作为参数的高阶函数
    看一下sumBy{}源码:

    阅读全文 »

ubuntu18 安装golang以及对go三个关键环境变量的理解

发表于 2019-01-29 | 分类于 golang |
字数统计: 801 | 阅读时长 ≈ 3

  vps的ip被封,更换ip的同时我顺带把原来的centos换成了ubuntu18,更换之后想着在服务器上重新玩一下golang,在重新安装golang的过程中我对golang的三个关键目录有了更深的理解,

我用的操作系统是Ubuntu 18.04 LTS

  • golang安装

    1
    2
    apt-get update
    apt-get install golang

    在终端执行这两条命令就可以安装上golang了

  • go三个关键目录

    阅读全文 »

kotlin学习(四)-面向对象

发表于 2019-01-23 | 分类于 kotlin |
字数统计: 2.2k | 阅读时长 ≈ 11

  

  • 写在本文之前:
      本文中会用到kotlin转java代码,所以这里附上使用intellij IDEA将kotlin转成java的方法:在idea中选中要查看的文件,在菜单栏中点击tools,找到kotlin,点击kotlin找到show kotlin bytecode,点击后会在窗口右边显示字节码,在字节码窗口的左上角有一个decompile,点击decompile就可以反编译成java代码

kotlin的面向对象在java的基础上做了很大的优化

  • 访问器
    在面向对象中,很多场景我们会对属性做一些限制,比如对某个属性只允许访问,不准修改,还有在对一些属性进行赋值时会进行一些校验

    阅读全文 »

kotlin学习(三)

发表于 2019-01-22 | 分类于 kotlin |
字数统计: 900 | 阅读时长 ≈ 4

  

  • for循环

    1
    2
    3
    4
    fun main(arg: Array<String>) {
    var a: Int? = null
    println(a)
    }

    跳出循环和其他语言的continue 和break 用法一致

  • foreach循环

    1
    2
    3
    4
    5
    6
    fun main(arg: Array<String>) {
    var a = "storm"
    a.forEach {
    println(it)
    }
    }
    阅读全文 »

kotlin学习(二)-可空类型

发表于 2019-01-21 | 分类于 kotlin |
字数统计: 513 | 阅读时长 ≈ 2

  据统计,市场上java程序的bug超过50%都是空指针异常,那么kotlin为了改善这个问题,加入了可空类型,在java程序中,变量可以直接赋值为null,但是在kotlin中不能这样

1
2
3
4
fun main(arg: Array<String>) {
var a: Int = null
println(a)
}

以上代码在编译的时候会报错,提示: error: null can not be a value of a non-null type Int
那么如果想要a变量可以赋值为null可以使用可空类型标示符”?”

  • 可空类型

    1
    2
    3
    4
    fun main(arg: Array<String>) {
    var a: Int? = null
    println(a)
    }

    在类型声明后面跟一个?号就可以定义一个可空变量,由可空类型又引出了安全调用符以及Elvis运算符

    阅读全文 »

java学习笔记5(多线程)

发表于 2019-01-15 | 分类于 java |
字数统计: 421 | 阅读时长 ≈ 2

  java提供了三种方式创建线程,实现runnable接口、继承thread类、通过callable和future创建线程

  • runnable接口实现线程

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    class RunnableThread implements Runnable {
    String name = null;

    public RunnableThread(String name){
    this.name = name;
    }

    public void run(){
    System.out.println("子线程run");
    try {
    for (int i = 5; i > 0; i--) {
    System.out.println(this.name + ":" + i);
    Thread.sleep(500);
    }
    }catch (InterruptedException e){
    e.printStackTrace();
    }
    }
    public void start(){
    System.out.println(this.name + "开始执行");
    Thread t = new Thread(this, this.name);
    t.start();
    }
    }

    public class test3 {
    public static void main(String[] args){
    RunnableThread th1 = new RunnableThread("thread1");
    th1.start();
    RunnableThread th2 = new RunnableThread("thread2");
    th2.start();
    }
    }
  • 继承thread

    阅读全文 »

java学习笔记4(IO流)

发表于 2019-01-15 | 分类于 java |
字数统计: 512 | 阅读时长 ≈ 2

  Java的stream按方向可以分为:输出流,输入流;按操作可以分为字节流,字符流。字节流和字符流都有输入和输出两个方向

  • 字节流
  1. 字节输入流
    以字节读取文件内容,每次读取一个字节:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    import java.io.*;
    import java.io.File;
    import java.io.FileInputStream;

    public class test3 {
    public static void main(String[] args)throws IOException{
    File file = new File("test.txt");
    FileInputStream fis = new FileInputStream(file);
    int b;
    while (( b = fis.read()) != -1){
    System.out.println((char)b);
    }
    fis.close();
    }
    }

    以字节读取文件内容,每次读取多个字节:

    阅读全文 »

kotlin学习(一)

发表于 2019-01-14 | 分类于 kotlin |
字数统计: 597 | 阅读时长 ≈ 2

  kotlin语言是ide开发公司JetBrains 出品的一个基于jvm的静态类型编程语言,2017年5月17日在旧金山召开的I/O开发者大会上,谷歌宣布Kotlin语言同java和C++一样成为Android的官方语言。

  • 安装
    macOS操作系统可以使用homebrew安装

    1
    2
    brew update
    brew install kotlin
  • hello world
    创建test.kt文件,写入代码

    1
    2
    3
    fun main(args: Array<String>){
    println("hello world!")
    }

    编译

    阅读全文 »

java学习笔记3-文件操作

发表于 2019-01-11 | 分类于 java |
字数统计: 447 | 阅读时长 ≈ 2

  

  • 创建文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    import java.io.File;
    import java.io.IOException;

    public class test3 {
    public static void main(String[] args){
    File file = new File("test.txt");
    if (!file.exists()){
    try {
    file.createNewFile();
    }catch(IOException e){
    e.printStackTrace();
    }
    }
    if (file.exists()){
    System.out.println("创建成功");
    }
    }
    }
  • 创建文件夹

    阅读全文 »
1234
fengxi

fengxi

宴安鸩毒 不可怀也

32 日志
10 分类
25 标签
GitHub
友情链接
  • wangfan
  • 森哥的博客
© 2020 fengxi | Site words total count: 23.4k
本站访客数:
博客全站共23.4k字