摘要:
/** * * @author gentleKay * Given a binary tree, determine if it is height-balanced. * For this problem, a height-balanced binary tree is defined as a 阅读全文
posted @ 2019-07-29 17:51
gentleKay
阅读(205)
评论(0)
推荐(0)
摘要:
接口是实现多重继承的途径,而生成遵循某个接口的对象的典型方式就是工厂方法设计模式。这与直接调用构造器不同,我们在工厂对象上调用的是创建方法,而该工厂对象将生成接口的某个实现的对象。 代码: 通过这种方式,我们就可以创建不同的自行车来复用这段代码。 来自 Thinking For Java. 阅读全文
posted @ 2019-07-29 16:41
gentleKay
阅读(302)
评论(0)
推荐(0)
摘要:
关于接口的定义,它根本没有提供任何具体实现,它允许创建者确定方法名,参数列表和返回类型,但是没有任何方法体。接口只提供了形式,而未提供任何具体实现。 接口 interface 关键字,可以在前面添加public关键字(仅限于该接口在于其同名文件中被定义),如果不添加public关键字,则它只具有包访 阅读全文
posted @ 2019-07-29 16:33
gentleKay
阅读(1927)
评论(0)
推荐(0)
摘要:
我们需要知道,由于为抽象类创建对象是不安全的,所以我们会从编译器那里得到一条出错消息。这样,编译器会确保抽象类的纯粹性,我们不必担心会误用它。 编译器直接报错提醒。 看一下完整的例子: 阅读全文
posted @ 2019-07-29 16:15
gentleKay
阅读(159)
评论(0)
推荐(0)
摘要:
/** * * @author gentleKay * A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). * The robot can only move 阅读全文
posted @ 2019-07-29 10:46
gentleKay
阅读(226)
评论(0)
推荐(0)
摘要:
/** * * @author gentleKay * Find the contiguous subarray within an array (containing at least one number) which has the largest sum. * For example, gi 阅读全文
posted @ 2019-07-29 10:26
gentleKay
阅读(177)
评论(0)
推荐(0)

浙公网安备 33010602011771号