From f5c839e45e32f3a66521702572460e4b1d2e3de7 Mon Sep 17 00:00:00 2001 From: CanaceYang <943546561@qq.com> Date: Wed, 27 Apr 2016 14:58:55 +0800 Subject: [PATCH 1/2] #1 #39 labs1 --- .../Net1314080903244activity.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java diff --git a/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java b/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java new file mode 100644 index 00000000..18f7d77d --- /dev/null +++ b/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java @@ -0,0 +1,52 @@ +package com.example.administrator.myapplication; + +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.View; +import android.view.Menu; +import android.view.MenuItem; + +public class Net1314080903244activity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); + fab.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) + .setAction("Action", null).show(); + } + }); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} From 094c780b1eb190f56430741910fc6a096b2a3970 Mon Sep 17 00:00:00 2001 From: CanaceYang <943546561@qq.com> Date: Wed, 27 Apr 2016 16:25:02 +0800 Subject: [PATCH 2/2] #1 #39 lab1 --- .../Net1314080903244activity.java | 229 ++++++++++++++---- 1 file changed, 188 insertions(+), 41 deletions(-) diff --git a/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java b/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java index 18f7d77d..93f42f45 100644 --- a/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java +++ b/edu/hzuapps/androidworks/homeworks/net1314080903244/Net1314080903244activity.java @@ -1,52 +1,199 @@ -package com.example.administrator.myapplication; - -import android.os.Bundle; -import android.support.design.widget.FloatingActionButton; -import android.support.design.widget.Snackbar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; -import android.view.View; -import android.view.Menu; -import android.view.MenuItem; - -public class Net1314080903244activity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); - setSupportActionBar(toolbar); - - FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { +package edu.hzuapps.androidworks; + +// java.lang.* + +import android.widget.TextView; + +import java.math.BigInteger; +import java.util.Date; +import java.io.File; +import java.util.StringTokenizer; + +import edu.hzuapps.androidworks.demo.StaticMethods; + +import static edu.hzuapps.androidworks.demo.StaticMethods.*; + +/** + * javadoc + * Created by zengsn on 16/3/11. + */ +public class Clazz { + + protected int i = 0; + private float f = 0.0f; + boolean b = false; + + + String str = "abc def ghi"; + Integer ii = null; + + StringBuffer strBuff = null; + StringBuilder strBui = null; + + + Clazz1 mClazz1 = new Clazz1(); + + int[] arr = new int[10]; + + public Clazz() { + } + + public Clazz(int i) { + this.i = i; + } + + void func() { + + + StringTokenizer strTok = new StringTokenizer(str); + while (strTok.hasMoreTokens()) { + String token = strTok.nextToken(); + } + + int bigInt = 1111111111; + BigInteger bi = new BigInteger("111111111111111111111111111111"); + + Integer iiii = 1; + Float fffff = 0.0f; + Boolean bbbbb = true; + + System.out.print(""); + System.currentTimeMillis(); + + int iii = MAX; + + Date date = new Date(); + + File file = new File(""); + + if (b) { + + } + + for (int j = 0; j < 10; j++) { + + } + + while (b) { + ; + } + + Class oneClass = this.getClass(); + + } + + public static void main(String[] args) throws ClassNotFoundException { + int i = 1; + int j = 2; + j = 0; + try { + int k = i / j; + // + // + } catch (RuntimeException e) { + // unchecked exception + throw new MyRuntimeException(); + } + Clazz clazz = new Clazz(); + + Class oneClass = Class.forName("edu.hzuapps.androidworks.Clazz"); + oneClass = Clazz.class; + // Method, Field, Contructor, Package, + try { + Object object = oneClass.newInstance(); + if (object instanceof Clazz) { + + } + clazz = (Clazz) object; // ClassCastException + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + + + Object object1 = clazz; + clazz.func(); + + + try { + Thread.sleep(1000*3); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + Thread current = Thread.currentThread(); + + Thread thread = new Thread(new Runnable() { @Override - public void onClick(View view) { - Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - .setAction("Action", null).show(); + public void run() { + System.out.print(">>>"); } }); + thread.run(); + + } +} + +class Clazz1 { + //private int i; + protected int j; + int k; + public int l; + + + void func() { + Clazz clazz = new Clazz(); } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // Inflate the menu; this adds items to the action bar if it is present. - getMenuInflater().inflate(R.menu.menu_main, menu); - return true; + public int getI() { + return 0; } - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle action bar item clicks here. The action bar will - // automatically handle clicks on the Home/Up button, so long - // as you specify a parent activity in AndroidManifest.xml. - int id = item.getItemId(); + public int getJ() { + return j; + } - //noinspection SimplifiableIfStatement - if (id == R.id.action_settings) { - return true; - } + public int getK() { + return k; + } - return super.onOptionsItemSelected(item); + public int getL() { + return l; + } + + public void setJ(int j) { + this.j = j; + } + + public void setK(int k) { + this.k = k; + } + + public void setL(int l) { + this.l = l; + } +} + +class Clazz2 { + + void func() throws MyException { + //this.j = 1; + throw new MyException(); } } + +class Clazz3 { + + void func() throws MyRuntimeException { + //this.j = 1; + throw new MyRuntimeException(); + } +} + +class MyException extends Exception { +} + +class MyRuntimeException extends RuntimeException { +} +