博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
java基础知识总结
阅读量:3906 次
发布时间:2019-05-23

本文共 2401 字,大约阅读时间需要 8 分钟。

这里写目录标题

Java相关基础知识

基础知识

1.java中获取数据的类型

package com.animals;import org.jsoup.Jsoup;import org.jsoup.nodes.Document;import org.jsoup.nodes.Element;import org.jsoup.select.Elements;public class TestXml {
private static String getType(Object a) {
return a.getClass().toString(); } public static void main(String[] args) throws Exception {
String html = "

Hello HTML

"; Document doc = Jsoup.parse(html); System.out.println("type="+getType(doc)); Elements as= doc.getElementsByTag("p"); for (Element e : as) {
System.out.println(e.text()); } }}

1.2将字符串写入到文件中

package com.animals;import java.io.FileOutputStream;public class TestXml {
private static String getType(Object a) {
return a.getClass().toString(); } public void WriteStringToFile5(String filePath) {
try {
FileOutputStream fos = new FileOutputStream(filePath); String s = "html"; fos.write(s.getBytes()); fos.close(); } catch (Exception e) {
// TODO Auto-generated catch block e.printStackTrace(); } } public static void main(String[] args) throws Exception {
String filePath = "E:\\link.html"; new TestXml().WriteStringToFile5(filePath); }}

1.3java方法中Collection集合的基本使用与方法

  1. 用于存储对象的容器。
  2. 集合的长度是可变的。
  3. 集合中不可以存储基本数据类型值。

第二章.进阶知识

2.1为多线程传递参数

传递的参数是整型数据a

调用start方法之前通过线程类的构造方法将数据传入线程。

package com.thread;public class MyThread1 extends Thread{
private String name; private int a; public MyThread1(String name,int a) {
this.name = name; this.a = a; } public void run() {
System.out.println("hello " + name); int b = a+5; System.out.println("result=" + b); } public static void main(String[] args) {
Thread thread = new MyThread1("world",9); thread.start(); }}

2.2通过变量和方法传递数据

package com.thread;public class MyThread2 implements Runnable{
private String name; public void setName(String name) {
this.name = name; } public void run() {
System.out.println("hello " + name); } public static void main(String[] args) {
MyThread2 myThread = new MyThread2(); myThread.setName("world"); Thread thread = new Thread(myThread); thread.start(); }}

转载地址:http://thqen.baihongyu.com/

你可能感兴趣的文章
如何修改postgresql中一个表的oid
查看>>
postgresql中快速对系统表实现vacuum full
查看>>
gp_configuration_history
查看>>
gp_distribution_policy
查看>>
postgresql 多行变一行,C语言自定义函数
查看>>
OpenSolaris新特性解析
查看>>
greenplum中在master上查看底层所有节点的sql语句
查看>>
greenplum(postgresql)之数据字典
查看>>
关于greenplum中的appendonly表
查看>>
Greenplum聚合函数的两种实现:HashAggregate与GroupAggregate
查看>>
postgresql/greenplum查询依赖于表上的视图
查看>>
Hbase shell 常用命令(1)
查看>>
greenplum is_date C语言接口
查看>>
Greenplum获取一个SQL结果的字段名
查看>>
JAVA Metrics 度量工具使用介绍1
查看>>
JAVA Metrics度量工具 - Metrics Core 翻译
查看>>
使用R语言画圆弧条形图
查看>>
关于P、NP、NPC和NP-Hard问题
查看>>
Java编写简单客户/服务器程序
查看>>
遗传算法解决TSP问题(C++)
查看>>