Android入门教程(五)
关注我,每天都有优质技术文章推送,工作,学习累了的时候放松一下自己。
欢迎大家关注我的微信公众号:「醉翁猫咪」
public class TestSwitch{
public static void main(String args []){
char c = 'a';
switch(c){
case 'b':
System.out.println('b');
break;
case 'c':
System.out.println('c');
break;
case 'a':
System.out.println('a');
break;
default:
System.out.println('d');
}
}
}
public class Test01{
public static void main(String args []){
int score = 90;
if(score > 85 && score <= 100){
System.out.println("成绩为优");
}
else if(score > 75 $$ score <= 85){
System.out.println("成绩为良");
}
else if(score > 60 $$ score <= 75){
System.out.println("成绩为中");
}
else if(score <= 60 && score >= 0){
System.out.println("成绩为差");
}
else if(score > 100 || score < 0){
System.out.println("成绩不在正常的范围之内");
}
}
}
public class TestWhile{
public static void main(String args []){
int i = 0;
while(i < 10){
System.out.println(i);
i++;
}
}
}
class TestPfrimeNumber{
public static void main(String args []){
for(int i = 100; i < 201; i++){
boolean b = false;
for(int j = 2 ; j < i - 1; j++){
int k = i % j;
if(k == 0){
b = true;
}
}
//如果不是true就打印出素数
if(!b){
System.out.println(i);
}
}
}
}
public class Test{
public static void main(String args[]){
int i = 5;
int j = i++ + 5;
System.out.println(j);
System.out.println(i);
}
}
class TestTriangle{
public static void main(String args []){
for(int i=1; i<5; i++){
for(int j=0; j<4-i; j++){
System.out.print(" ");
}
for(int k=0; k<i; k++){
System.out.print("* ");
}
System.out.println("");
}
}
}
什么是面向对象?
应该如何学习面向对象?
什么是面向对象思维方法?
14
class Test{
public static void main(String args []){
Dog d = new Dog();
d.name="旺财";
d.age=2;
d.color="黑色";
d.jump();
System.out.println("名字是"+d.name);
}}
对象的使用方法,多对象的创建方法,匿名对象的创建和使用方法。
匿名对象的使用
函数的重载和构造函数的作用
重载的表达
class A{
void funA(){
System.out.println("没有参数的funA函数");
}
void funA(int i){
System.out.println("拥有一个整型参数的funA函数");
}
void funA(int i,double d){
System.out.println("拥有两个参数的funA函数");
}
class Test{
public static void main(String args[]){
A a = new A();
a.funA();
a.funA(1,3.2);
}
}
什么叫函数的重载呢?
什么是构造函数?
class Person{
static{
System.out.println("dd");
}
static String name;
..
}
继承,封装,多态
什么是继承?
Java当中只支持单继承
class Person{
String name;
int age;
Person(){
System.out.println("Person的无参数构造函数");
}
Person(String name,int age){
this.name = name;
this.age = age;
System.out.println("Person有参数构造函数");
}
void eat(){
System.out.println("吃饭");
}
}
class Student extends Person{
//在子类的构造函数当中,必须调用父类的构造函数
Student(){
super();
System.out.println("Student的无参数构造函数");
}
Student(String name,int age,int a){
super(name,age);
this.a = a;
}
继承只能继承成员变量成员函数
class Test{
public static void main(String args[]){
Student student = new student();
}
}
虽然子类不能继承父类的构造函数,但我能用super()来调用父类的构造函数。
调用子类的构造函数,一定会调用父类的构造的函数。
函数的复写(override)
class Student extends Person{
String address;
void introduce(){
super.introduce();
System.out.println("我的家在"+address);
}
}
对象的转型(多态性的体现)
对象的向上转型和向下转型
class Test{
public static void main(String args[]){
String s = new Student();
Person p = s;
p.name = "hhh";
p.age = 20;
//p.address = "beijing";
p.introduce();
//p.study();
}
}
什么是向下转型?
抽象类的语法特征
抽象类的作用
什么是抽象函数?
abstract void fun();
class Person{
String name;
int age;
void introduce(){
System.out.println("我的名字是"+name+",我的年龄是"+age);
}
abstract void eat();
}
什么是抽象类?
抽象类可以有构造函数吗?
abstract class Person{
Person(){
System.out.println("Person的构造函数");
}
Person(String name,String age){
this.name = name;
this.age = age;
}
String name;
int age;
void introduce(){
System.out.println("我的名字是"+name+",我的年龄是"+age);
}
abstract void eat();
}
class Chinese extends Person{
String address;
Chinese(){
super();
System.out.println("Chinese的构造函数");
}
Chinese(String name,int age,String address){
super(name,age);
this.address = address;
}
void eat(){
System.out.println("用筷子吃饭");
}
}
class Test{
public static void main(String args[]){
Person p = new Chinese();
P.eat();
}
}
24为什么用抽象类。
abstract class Printer{
void open(){
System.out.println("open");
}
void close(){
System.out.println("close");
}
abstract void print();
}
25什么是Java当中的软件包?
package hhh;
class Test{
public static void main(String args[]){
System.out.println("hellos");
}
}
27包和访问权限
package com.hh;
public class Person{
String name;
int age;
void eat(){
System.out.println("eat");
}
void sleep(){
System.out.println("sleep");
}
}
package cn.mm;
import com.hh;
class Student extends Person{
void introduce(){
System.out.println("我的名字是"+name+",haha"+age);
}
}
从入门到熟悉!
坚决不放弃!
![]()
喜欢本文的朋友们
欢迎长按下图关注订阅号醉翁猫咪
收看更多精彩内容
Android入门教程(五)的更多相关文章
- Android入门教程(四)
关注我,每天都有优质技术文章推送,工作,学习累了的时候放松一下自己. 本篇文章同步微信公众号 欢迎大家关注我的微信公众号:「醉翁猫咪」 学习Android要掌握Android程序结构,和通信技术,和如 ...
- 无废话ExtJs 入门教程五[文本框:TextField]
无废话ExtJs 入门教程五[文本框:TextField] extjs技术交流,欢迎加群(201926085) 继上一节内容,我们在表单里加了个两个文本框.如下所示代码区的第42行位置,items: ...
- PySide——Python图形化界面入门教程(五)
PySide——Python图形化界面入门教程(五) ——QListWidget 翻译自:http://pythoncentral.io/pyside-pyqt-tutorial-the-qlistw ...
- Android入门教程(二)
Hello World 项目 首先当我们启动Android Studio的虚拟机时,可以看到第一个项目Hello World,那么虚拟机中的Hello World!是如何书写的呢? 看看虚拟机运行结果 ...
- Elasticsearch入门教程(五):Elasticsearch查询(一)
原文:Elasticsearch入门教程(五):Elasticsearch查询(一) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:h ...
- RabbitMQ入门教程(五):扇形交换机发布/订阅(Publish/Subscribe)
原文:RabbitMQ入门教程(五):扇形交换机发布/订阅(Publish/Subscribe) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. ...
- linux.linuxidc.com - /2011年资料/Android入门教程/
本文转自 http://itindex.net/detail/15843-linux.linuxidc.com-%E8%B5%84%E6%96%99-android Shared by Yuan 用户 ...
- WebGL入门教程(五)-webgl纹理
前面文章: WebGL入门教程(一)-初识webgl WebGL入门教程(二)-webgl绘制三角形 WebGL入门教程(三)-webgl动画 WebGL入门教程(四)-webgl颜色 这里就需要用到 ...
- Android入门教程之我见
真正的从安卓入门学习到实际工作也差不多一年时间了,也做了几个项目.在这期间经历了一开始学习Android的基本知识后仍旧无从下手,不知道如何开始开发一个app,到现在也开始学会注意Android架构的 ...
- WCF入门教程五[WCF的通信模式]
一.概述 WCF在通信过程中有三种模式:请求与答复.单向.双工通信.以下我们一一介绍. 二.请求与答复模式 描述: 客户端发送请求,然后一直等待服务端的响应(异步调用除外),期间处于假死状态,直到服务 ...
随机推荐
- springcolud 的学习(四)服务治理. Eureka
什么是服务治理在传统rpc远程调用中,服务与服务依赖关系,管理比较复杂,所以需要使用服务治理,管理服务与服务之间依赖关系,可以实现服务调用.负载均衡.容错等,实现服务发现与注册.服务注册与发现 在服务 ...
- ASP.NET Nlog上手练习小例子
添加NuGet程序包- Nlog Nlog.Web.AspNetCore 两个包. public void Configure(IApplication ...
- Java实现树的遍历以及打印(递归,非递归)
import java.util.LinkedList; import java.util.Stack; public class BinarySearchTree1<E extends Com ...
- Kubernetes第十一章--部署微服务电商平台
- pandas-08 pd.cut()的功能和作用
pandas-08 pd.cut()的功能和作用 pd.cut()的作用,有点类似给成绩设定优良中差,比如:0-59分为差,60-70分为中,71-80分为优秀等等,在pandas中,也提供了这样一个 ...
- 【转载】 C#中使用decimal.Parse方法将字符串转换为十进制decimal类型
在C#编程过程中,很多时候涉及到数据类型的转换,例如将字符串类型的变量转换为十进制decimal类型就是一个常见的类型转换操作,decimal.Parse方法是C#中专门用来将字符串转换为decima ...
- BFC特性及其简单应用
BFC是什么? BFC(Block Formatting Context)中文直译就是‘块级格式上下文’,它是 W3C CSS 2.1 规范中的一个概念,它决定了元素如何对其内容进行定位,以及与其他元 ...
- localStorage&sessionStorage&Cookie
localStorage.sessionStorage.Cookie三者区别如下:
- 因改漏洞而引申了解的Cookie机制!
近期因为修改漏洞:Appscan扫描漏洞:加密会话(SSL)Cookie中缺少Secure属性,而涉及到Cookie有关的知识,现结合该漏洞的修复过程和了解的cookie知识总结一下. 一.加密会话( ...
- maven学习笔记二(了解maven的基本命令)
maven常用的命令 mvn archetype:create 创建Maven项目 mvn compile 编译源代码 mvn deploy 发布项目 mvn test-compile 编译测试源代码 ...