4.1. Introduction to Object-Oriented ProgrammingObject-oriented programming, or OOP for short, is the dominant programming paradigm these days, having replaced the "structured," procedural programming techniques that were developed in the 1970s.…
1.2. The Java "White Paper" BuzzwordsThe authors of Java have written an influential White Paper that explains their design goals and accomplishments. They also published a shorter summary that is organized along the following 11 buzzwords:1. Si…
4.7. PackagesJava allows you to group classes in a collection called a package. Packages are convenient for organizing your work and for separating your work from code libraries provided by others.The standard Java library is distributed over a numbe…
3.10. ArraysAn array is a data structure that stores a collection of values of the same type. You access each individual value through an integer index. For example, if a is an array of integers, then a[i] is the ith integer in the array.Declare an a…
3.8. Control FlowJava, like any programming language, supports both conditional statements and loops to determine control flow. We will start with the conditional statements, then move on to loops, to end with the somewhat cumbersome switch statement…
5.1. Classes, Superclasses, and SubclassesLet's return to the Employee class that we discussed in the previous chapter. Suppose (alas) you work for a company at which managers are treated differently from other employees. Managers are, of course, jus…
4.10. Class Design HintsWithout trying to be comprehensive or tedious, we want to end this chapter with some hints that will make your classes more acceptable in well-mannered OOP circles. 1. Always keep data private. This is first and foremost; doin…
4.6. Object ConstructionYou have seen how to write simple constructors that define the initial state of your objects. However, since object construction is so important, Java offers quite a variety of mechanisms for writing constructors. We go over t…
4.5. Method ParametersLet us review the computer science terms that describe how parameters can be passed to a method (or a function) in a programming language. The term call by value(值调用) means that the method gets just the value that the caller pro…
4.4. Static Fields and MethodsIn all sample programs that you have seen, the main method is tagged with the static modifier. We are now ready to discuss the meaning of this modifier.4.4.1. Static Fields(静态域)If you define a field as static, then there…
3.6. StringsConceptually, Java strings are sequences of Unicode characters(Java的字符串是一个Unicode序列). For example, the string "Java\u2122" consists of the five Unicode characters J, a, v, a, and ?. Java does not have a built-in string type(Java没有内置的…
3.5. OperatorsThe usual arithmetic operators +, -, *, / are used in Java for addition, subtraction, multiplication, and division. The / operator denotes integer division if both arguments are integers, and floating-point division otherwise. Integer r…
3.4. VariablesIn Java, every variable has a type. You declare a variable by placing the type first, followed by the name of the variable. Here are some examples: double salary; int vacationDays; long earthPopulation; boolean done; Notice the semicolo…
3.3. Data TypesJava is a strongly typed language(强类型语音). This means that every variable must have a declared type(每个变量都必须声明类型). There are eight primitive types in Java(Java有8种原始类型). Four of them are integer types; two are floatingpoint number types;…
Let’s look more closely at one of the simplest Java programs you can have—one that simply prints a message to console: public class FirstSample { public static void main(String[] args) { System.out.println("We will not use 'Hello, World!'"); } }…
今天重扫了corejava 14 并发的一章,在谈到volatile域代替synchronized 应用于并发更新时,看到如下内容,并发更新可用内部锁的方式但会带来阻塞问题,可用volatile域替代.个人发觉好像有哪里欠了点逻辑,似乎volatile域为什么能替代内部锁并没有讲明原因.秉承着疑惑对了一下原版. 果然在原版中多了这么一句解释: The compiler will insert the appropriate code to ensure that a change to the…
Static and non-Static :  非静态方法(不带static)可以访问静态变量和方法(带static),但是反过来就不行. 类的静态成员(变量和方法)属于类本身,在类加载的时候就会分配内存,可以通过类名直接去访问. 非静态成员(变量和方法)属于类的对象,只有在类的对象产生(创建实例)的时候才会分配内存,然后通过类的对象去访问. 在一个类的静态成员中去访问非静态成员之所以会出错是因为在类的非静态成员不存在的时候静态成员就已经存在了,访问一个内存中不存在的东西会出错. 静态变量和方…
swift面向协议编程的根本原因在于值类型的存在:面向对象必须要有引用类型的支持: Protocol Oriented approach was introduced to resolve some issues in programming and it also differs in various scenarios when compared to Object-Oriented programming. So let’s dive into the topic. What is Pro…
今天起开始学习Java,学习用书为Core Java.之前有过C的经验.准备把自己学习这一本书时的各种想法,不易理解的,重要的都记录下来.希望以后回顾起来能温故知新吧.也希望自己能够坚持把自己学习这本书的整个过程记录下来. I want to put a ding in the universe. 基本术语:       Object Oriented Programming——OOP——面向对象编程 Application Programming Interface——API——应用程序编程接…
MODULE 5 OOP 面向对象程序设计--------------------------------------------------------Object Oriented Programming 缩写 Class类/Object对象--------------------万物皆对象 类:具有相同属性和行为的一组对象的组合 class 类名{ 属性 构造器 方法 }对象:类的一个实例 new 类名 OOP三大特性1.封装Encapsulation 封装的目的:实现信息的隐藏 1)实现…
三.Spring的核心之AOP(Aspect Oriented Programming 面向切面编程) 1.AOP概念及原理 1.1.什么是AOP OOP:Object Oriented Programming面向对象编程 AOP:Aspect Oriented Programming面向切面编程 1.2.代理 充分理解:间接 主要作用:拦截被代理对象执行的方法,同时对方法进行增强. 1.2.1.静态代理 特点:代理类是一个真实存在的类.装饰者模式就是静态代理的一种体现形式. 1.2.2.动态代…
class fun { public static void main(String[] args) { String str="java is an object oriented programming language"; String[] strs = str.split(" "); int sum = 0; for(int i=0;i<strs.length;i++) { sum += strs[i].length(); System.out.pri…
Difference between Vector and Arraylist is the most common  Core Java Interview question you will come across in Collection .  This question is mostly used as a start up question by the Interviewers before testing deep  roots of  the Collection  .Vec…
import java.awt.BorderLayout; import java.awt.EventQueue; import java.awt.Font; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URL; import javax.swing.JApplet; import javax.swing.JBu…
This is a new series of sharing core Java interview question and answer on Finance domain and mostly on big Investment bank.Many of these Java interview questions are asked on JP Morgan, Morgan Stanley, Barclays or Goldman Sachs. Banks mostly asked c…
Java里面的String Conceptually, Java Strings are sequences of Unicode characters. Java里面的String都是Unicode字符串 Java does not have a built-in string type. java没有内建的字符串类型. Each quoted string is an instance of the String class. 每个引用的字符串都是一个String类的实例. 字符串是永恒的:…
We are sharing 25 java interview questions , these questions are frequently asked by the recruiters.Java questions can be asked from any core java topic . So we try our best to provide you the java interview questions and answers for experienced whic…
Core Java (十一) Java 继承,类,超类和子类 标签: javaJavaJAVA 2013-01-22 17:08 1274人阅读 评论(0) 收藏 举报  分类: java(58) 读书笔记(46)  版权声明:本文为博主原创文章,未经博主允许不得转载.   目录(?)[+]   继承关系 两个类之间存在三种关系: 依赖,uses-a,如果一个类的方法操纵另一个对象,我们就说一个类依赖于另一个类. 聚合(关联),has-a,一个对象包含另外一个对象,聚合关系意味着类A的对象包含类…
Core Java的那点事儿之ArrayList 万丈高楼平地起,Java基础要拿起.今天就从我看的Core Java里找了些小基础点来分享一下. 首先隆重介绍一下专业级龙套演员---Employee类(PS:我可是专注龙套30年),下面会有多次出场,因此先在此介绍一下: class Employee{ private String name; private double salary; private int id; //下面是set.get方法 } ArrayList 首先有请ArrayL…
初始化空 初始化创建 一把锁 两把锁 大专栏  Core Java之7种单例模式"headerlink" title="静态内部类">静态内部类 静态加载 枚举…