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在通信过程中有三种模式:请求与答复.单向.双工通信.以下我们一一介绍. 二.请求与答复模式 描述: 客户端发送请求,然后一直等待服务端的响应(异步调用除外),期间处于假死状态,直到服务 ...
随机推荐
- springboot使用HttpSessionListener 监听器统计当前在线人数
概括: request.getSession(true):若存在会话则返回该会话,否则新建一个会话. request.getSession(false):若存在会话则返回该会话,否则返回NULL ht ...
- FastJson前置属性过滤器
FastJson前置属性过滤器 /** * <html> * <body> * <P> Copyright 1994 JsonInternational</p ...
- java之spring mvc之拦截器
1. springmvc 中的拦截器是由实现 HandlerInterceptor 或者继承 HandlerInterceptorAdapter 来实现的. 2. 自定义实现一个拦截器的步骤: a). ...
- Nikitosh 和异或(trie树)
题目: #10051. 「一本通 2.3 例 3」Nikitosh 和异或 解析: 首先我们知道一个性质\(x\oplus x=0\) 我们要求\[\bigoplus_{i = l}^ra_i\]的话 ...
- 一个非常有趣的爬虫小练习带ocr识别的
有个小的想法,想找一找 形近字 .百度一搜索,百度文库有一个,收费4元.而且我觉得字数不是太多.想自己弄一个,于是找到了 这个网站 http://www.fantiz5.com/xingjinzi/ ...
- sdcard不可执行.
Possibly you placed it on your sdcard -- which is mounted with the noexec flag. You either need to m ...
- iOS 12中获取WiFi的SSID
开始搞智能家居,wifi获取不到了?? 小插曲 旧方法失效,19-12-15更新,ios13开始需要请求定位信息 SSID全称Service Set IDentifier, 即Wifi网络的公开名称. ...
- 两种方法实现在HTML页面加载完毕后运行JS
JS默认方法: <script type=”text/javascript”> window.onload=function (){ /*代码区域*/ } </script> ...
- ES6 新增基本数据类型Symbol
ES6 增加了一个新的基本数据类型 symbol. 不过,和其他基本数据类型相比,它有点与众不同,因为它没有字面量的表现形式,而且创建的方式也有点奇怪,只能通过调用全局函数Symbol()来完成. l ...
- 非洲affrike单词
affrike 英文单词,含义是非洲,非洲大陆. 中文名:非洲 外文名:affrike 目录 释义 affrike noun名词 非洲,也用做africa 1.Word Origin and Hist ...