- 博客(131)
- 资源 (2)
- 收藏
- 关注
原创 经典SQL语句练习
数据库设计学生表 student(Sid,Sname,Sage,Ssex) Sid 学生编号,Sname 学生姓名,Sage 出生年月,Ssex 学生性别课程表 course(Cid,Cname,Tid) Cid 课程编号,Cname 课程名称,Tid 教师编号教师表 teacher(Tid,Tname) Tid 教师编号,Tname 教师姓名4.成绩表 SC(...
2018-08-14 16:30:40
3436
原创 Hadoop2.6.5完全分布式集群搭建
环境配置: 虚拟机: vmware workstation 12 系统: ubuntu 16.04 LTS 节点: 192.168.254.113 master 192.168.254.130 node1
2018-01-15 10:11:56
1648
转载 在VMWare虚拟机中安装Ubuntu 16.04.1 LTS
一、需要的准备安装好VMWare虚拟机(傻瓜式安装,一直next就可以,请支持正版),将Ubuntu的系统镜像下载好,目前最新的LTS版本为16.04.1。 我把虚拟机和Ubuntu镜像传到了百度云里,需要的可以下载。链接:http://pan.baidu.com/s/1nvyhwHb 密码:2cjv 如果Ubuntu镜像有什么问题,也可以到官网下载
2018-01-13 10:29:49
1314
原创 win10中jdk版本修改后报错解决
win10系统,把jdk1.8换成1.7后,命令行中java -version发现版本号还是1.8。 报错:Error: Registry key ‘Software\JavaSoft\Java Runtime Environment’\CurrentVersion’ has value ‘1.7’, but ‘1.8’ is required. Error: could not find ja
2018-01-09 19:50:57
908
转载 Thread的run()与start()的区别
java的线程是通过java.lang.Thread类来实现的。VM启动时会有一个由主方法所定义的线程。可以通过创建Thread的实例来创建新的线程。每个线程都是通过某个特定Thread对象所对应的方法run()来完成其操作的,方法run()称为线程体。通过调用Thread类的start()方法来启动一个线程。在Java当中,线程通常都有五种状态,创建、就绪、运行、阻塞和死亡。
2017-10-23 15:21:57
315
转载 final关键字
一.final关键字的基本用法 在Java中,final关键字可以用来修饰类、方法和变量(包括成员变量和局部变量)。下面就从这三个方面来了解一下final关键字的基本用法。 1.修饰类 当用final修饰一个类时,表明这个类不能被继承。也就是说,如果一个类你永远不会让他被继承,就可以用final进行修饰。final类中的成员变量可以根据需要设为final,但是要注意final类中
2017-09-19 13:48:04
478
转载 volatile关键字解析
volatile这个关键字可能很多朋友都听说过,或许也都用过。在Java 5之前,它是一个备受争议的关键字,因为在程序中使用它往往会导致出人意料的结果。在Java 5之后,volatile关键字才得以重获生机。volatile关键字虽然从字面上理解起来比较简单,但是要用好不是一件容易的事情。由于volatile关键字是与Java的内存模型有关的,因此在讲述volatile关键之前,我们先来
2017-09-19 11:10:54
9343
转载 Lock与synchronized的区别
1)Lock是一个接口,而synchronized是Java中的关键字,synchronized是内置的语言实现; 2)synchronized在发生异常时,会自动释放线程占有的锁,因此不会导致死锁现象发生;而Lock在发生异常时,如果没有主动通过unLock()去释放锁,则很可能造成死锁现象,因此使用Lock时需要在finally块中释放锁; 3)Lock可以让等待锁的线程响
2017-09-19 10:52:16
747
原创 适配器模式
适配器模式的结构 适配器模式有类的适配器模式和对象的适配器模式两种不同的形式。类适配器模式 类的适配器模式把适配的类的API转换成为目标类的API。 在上图中可以看出,Adaptee类并没有sampleOperation2()方法,而客户端则期待这个方法。为使客户端能够使用Adaptee类,提供一个中间环节,即类Adapter,把Adaptee的API
2017-09-18 23:41:42
405
转载 工厂模式
工厂模式:主要用来实例化有共同接口的类,工厂模式可以动态决定应该实例化那一个类。 工厂模式的形态 工厂模式主要用一下几种形态: 1:简单工厂(Simple Factory)。 2:工厂方法(Factory Method)。 3:抽象工厂(Abstract Factory)。 简单工厂(Simple Factory) 又叫静态工厂,是工厂模式三中状态中结构最为简单的。
2017-09-18 12:36:38
441
转载 红黑树
红黑树(英语:Red–black tree)是一种自平衡二叉查找树,是在计算机科学中用到的一种数据结构,典型的用途是实现关联数组。它是在1972年由鲁道夫·贝尔发明的,他称之为"对称二叉B树",它现代的名字是在Leo J. Guibas和Robert Sedgewick于1978年写的一篇论文中获得的。它是复杂的,但它的操作有着良好的最坏情况运行时间,并且在实践中是高效的:它可以在{\disp
2017-09-12 16:01:31
328
转载 DNS原理及其解析过程 精彩剖析
DNS原理及其解析过程精彩剖析 网络通讯大部分是基于TCP/IP的,而TCP/IP是基于IP地址的,所以计算机在网络上进行通讯时只能识别如“202.96.134.133”之类的IP地址,而不能认识域名。我们无法记住10个以上IP地址的网站,所以我们访问网站时,更多的是在浏览器地址栏中输入域名,就能看到所需要的页面,这是因为有一个叫“DNS服务器”的计算机自动把我们的域名
2017-09-12 15:09:50
367
原创 单例模式
1. 什么是单例模式 单例模式有以下特点: 1、单例类只能有一个实例。 2、单例类必须自己创建自己的唯一实例。 3、单例类必须给所有其他对象提供这一实例。不妨举一个具体的单例模式的例子:比如教室里面的教师和学生都是需要在黑板上写字的,但是一般的情况下,教室里面应该只有一个黑板吧,它是教师和学生公用滴。这时就要想办法保证取得的黑板是一个共享的唯一的对象。而单例模式就是解决这类问题的一
2017-09-07 12:54:23
295
原创 从尾到头打印单链表
public class Solution { public ArrayList<Integer> printListFromTailToHead(ListNode listNode) { ArrayList<Integer> result = new ArrayList<>(); Stack<ListNode> stack = new Stack<>();
2017-09-03 23:08:06
250
原创 Scramble String
题目描述Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 ="great": great / \ gr
2017-08-29 21:38:10
407
原创 排序算法
直接插入排序import java.util.Arrays;//直接插入排序public class StraightInsertionSort { public static void InsertSort(int[] A) { for (int i = 1; i < A.length; i++) { int target = A[i];
2017-08-21 15:39:56
244
原创 java访问修饰符
protectedprotected表示被其修饰的成员可以被本类, 同包下的所有类, 以及本类的所有子类所访问。这里的子类可以在其它包下。package jvmSrgumens;//当前包下public class Test1 { protected int a=9;}package jvmSrgumens;//当前包下的子类public class Tesy3 extends T
2017-07-27 17:01:51
270
原创 word-ladder
题目描述Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word
2017-07-11 21:50:41
346
原创 JVM学习笔记(四)垃圾收集器
CMS收集器CMS(Concurrent Mark Sweep年老代)年老代收集器。采用 ”标记-清除“算法,可以通过设置参数在垃圾回收时进行内存碎片的整理。 1、UserCMSCompactAtFullCollection:默认开启,FullGC时进行内存碎片整理,整理时用户进程需停止,即发生Stop The World 2、CMSFullGCsBeforeCompaction:设置执行多
2017-07-10 17:38:10
379
原创 JVM学习笔记(四)对象已死吗
堆中存放着java中几乎所有的对象实例,垃圾收集器在堆堆进行回收前,首先要确定这些对象哪些还“活着”,哪些已经“死去”。有如下两种方法:引用计数算法 为对象添加一个引用计数器,每当有一个地方引用该对象时,则该引用计数器值加1,;当引用失效时,则该引用计数器值减1;最后,计数器为0的对象就是不可能再被使用的,也即所谓的“死去”的对象。 Java虚拟机中并没有选用引用计算算法来管理内存,主要原因是很
2017-07-10 12:36:14
315
转载 JVM学习笔记(三)垃圾收集算法
Java虚拟机JVM垃圾收集算法有四种:标记-清除算法、复制算法、标记-整理算法以及分代收集算法。标记-清除算法这是JVM最基础的垃圾收集算法。如下图: 该算法分为两个阶段:“标记”和“清除”。首先标记处所有需要回收的对象,然后统一清除被标记的对象。 该算法,标记和清除两个阶段的效率不高。此外,回收后会产生大量的不连续的内存碎片,分配较大对象时,无法找到足够大连续内存,进一步
2017-07-10 10:40:06
286
原创 MongoDB增删改查(三)
Insert Documents插入单个document到collection中. db.inventory.insertOne( { item: “canvas”, qty: 100, tags: [“cotton”], size: { h: 28, w: 35.5, uom: “cm” } } )插入多个document到collection中 db.inventor
2017-06-19 09:31:41
1949
原创 MongoDB常用操作(二)
下载MongoDB 进到官网下载你需要的MondoDB版本,这里我们现在mongodb-win32-x86_64-2008plus-ssl-3.2.13.zip这个版本。安装MongoDB把下载后的zip压缩包解压,进入到bin目录下,鼠标右指键此处命令行打开,或者在系统的环境变量path下配置bin的路径。启动MongoDB在启动MongoDB之前,要手动创建一个存放MongoDB数据文件的目录
2017-06-18 11:40:53
567
原创 MongoDB简介和基本概念(一)
NoSQL简介 NoSQL(Not Only SQL ),意即“不仅仅是SQL” ,指的是非关系型的数据库 。是一项全新的数据库革命性运动,早期就有人提出,发展至2009年趋势越发高涨。NoSQL的拥护者们提倡运用非关系型的数据存储,相对于铺天盖地的关系型数据库运用,这一概念无疑是一种全新的思维的注入。 关系型数据库中的表都是存储一些结构化的数据,每条记录的字段的组成都一样,即使不是每条记
2017-06-16 11:56:26
9480
1
原创 remove-duplicates-from-sorted-array
题目描述 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in plac
2017-06-05 23:02:40
291
原创 remove element
题目描述 Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn’t matter what you leave beyond the new length
2017-06-05 22:48:41
265
原创 Next Permutation
题目描述 Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest po
2017-06-05 22:37:20
233
原创 first-missing-positive
题目描述 Given an unsorted integer array, find the first missing positive integer. For example, Given[1,2,0]return3, and[3,4,-1,1]return2. Your algorithm should run in O(n) time and uses cons
2017-06-05 18:50:22
226
原创 旋转二维数组90度
题目You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?java实现public void rotate(int[][] matrix) { int row =
2017-06-05 15:51:33
627
原创 spiral-matrix
题目描述Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You sh
2017-06-05 14:54:28
325
原创 merge-intervals
题目描述 Given a collection of intervals, merge all overlapping intervals. For example, Given[1,3],[2,6],[8,10],[15,18], return[1,6],[8,10],[15,18].java实现public ArrayList<Interval> merge(ArrayL
2017-06-05 12:23:33
305
原创 plus-one
题目描述 Given a number represented as an array of digits, plus one to the number.分析digits数组代表一个大整数,将这个大整数加1.如果末尾位上的数小于9,直接将该位加1.如果末尾位置上的数大于9,将该位置0,产生进位。public int[] plusOne(int[] digits) { for
2017-06-05 10:53:04
283
原创 search-a-2d-matrix
题目描述Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each row
2017-06-04 22:20:59
261
原创 sorts-colors
题目:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0
2017-06-04 21:49:59
215
原创 (有序数组中移除重复元素)Remove Duplicates from Sorted Array
题目: Follow up for “Remove Duplicates”: What if duplicates are allowed at most twice? For example, Given sorted array A =[1,1,1,2,2,3], Your function should return length =5, and A is now[
2017-05-31 23:21:38
449
原创 合并有序数组
题目: Given two sorted integer arrays A and B, merge B into A as one sorted array. Note: You may assume that A has enough space to hold additional elements from B. The number of elements init
2017-05-31 21:35:37
292
原创 升序数组转成二叉排序树
题目 Given an array where elements are sorted in ascending order, convert it to a height balanced BST.分析将二叉查找树进行中序遍历,就可以得到一个升序排序的数组,因此,一个已经排序的数组可以看做一个中序遍历得到的数组,要得到一个高度平衡的二叉查找树,可以使得左右子树的节点数尽可能相等。因此,可以采
2017-05-31 00:10:36
2130
原创 买卖股票 I II III
Best Time to Buy and Sell Stock IDescription: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie,
2017-05-30 23:05:46
465
原创 数组中最长的连续序列(longest consecutive sequence)
题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given[100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is[1, 2, 3, 4].
2017-05-30 20:37:55
967
原创 二叉树的最小深度
题目 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.java实现public int run(TreeNode root) {
2017-05-25 22:52:11
340
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人