java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

java Instanceof判断一个对象的类型

instanceof 用来判断一个对象(Object)是否为某一个类型 比如String str = "abc". str是否为String类型 HashMap m = new HashMap m 是否为一个hashmap instanceof常用于,知道一个Object,但是后面的代码需要判断Object的类型。 package com.javaer.examples; import java.util.HashMap; public class TestInstance { /** * @param More


Java继承inheritance

Java继承 Java inheritance 我们可以把继承看成是儿子,继承了父亲的一些特点,但是儿子可以有一些改变。 java里儿子继承了父亲的公共属性 和公共方法,儿子可以修改这些属性和方法。儿子修改父亲的公共属性,我们叫重载。没有修改的叫继承。 We can think of that their children inherit their father, the child can have the father of all public More


java abstract抽象类学习

java抽象类 java abstract class 有时候,我们需要用到抽象类。比如我们想买水果,但是不确定买的是苹果还是香蕉 Sometimes, we want to abstract a class.For example, We want buy some fruits,but we are not sure we buy apple or pear. 我们抽象出一个类叫水果 Now we can abstract a class named Fruit 水果就作为了一个抽象类和一个父亲类 Fruit More


14. java 数组学习

我们来使用java的数组的例子,来学习一下java的数组使用。 例子1 数字数组 int[] stu = new int[2] 例子2 字符串数组 String[] str = new String[3]; //3 表示数组长度 例子3 二纬数组 String[][] tarr = new String[2][2]; 建立文件JavaArray.java /** java-er.com learn java is so easy */ import java.util.*; public class JavaArray { pub More


03. java 算术运算符

算术基本就是和数字有关系加减乘除 Java 中的算术运算符主要用来组织数值类型数据的算术运算,按照参加运算的操作数的不同可以分为一元运算符和二元运算符。 1. 一元运算符 一个变量自己玩 运 算 符 名 称 说 明 例 子 -  取反符号 取反运算 b=-a ++ 自加一 先取值再加一,或先加一再取值 a++ 或 ++a More


java里的final和static使用方法

final变量被定义为一个常量,是一个无法修改的量。我们只能给他赋值一次。 final, the variable can be defined as a constant and can not be changed;we only assgin the value for the final variable once. final定义的方法,无法被重写。 final, the definition of the method can not be covered; final定义的类,不能被继承 final, the definiti More


java两种方法写入文件

两种办法写入文件。 Two way for writing the files in java. one,we don't need to assgin the file's encoding 一个不需要指定encode another,we can assgin the file's encoding before we write this file 一个需要指定。常见于写一个utf-8的文件 package com.javaer.examples.file; import java.io.File; import java.io.FileOutputStream; im More


两种读取文件的java方法,java.io.file

两种读取文件的java方法 Two way for reading the files in java. one,we don't need to know what is file's encoding 一个不用知道文件的编码 another,we must know the file's encoding before we read this file 另外一个,必须在读取之前知道文件编码 package com.javaer.examples.file; import java.io.BufferedReader; import java.io.ByteA More


java private,protected,default,public 的区别

这些英文版的文章,以前写的,现在翻译成中文。希望对大家有帮助 Java Access Modifiers 1. private 2. protected 3. default 4. public 1.private. if a method is private , you only use it in it's self class 如果方法为pricate,只能在自己的class里使用 2.default. if a metod is default.you can use it in the clas More


java interface教程

java interface就是表示一个接口,接口只有方法,但是没有实际的实现。实现他的接口可以采用不同的程序。 Java the interface is a set of methods statement to be some method features, a set of interfaces only methods of characteristics of no method to realize, so these methods can in different places were different class implements, and these More