java练习程序1
/*import javax.swing.JFrame;*/
/*import javax.swing.JOptionPane;*/
public class TestFrame{
public static void main(String[] args) throws Exception{
/*JFrame frame1 = new JFrame();
frame1.setTitle("Windows 1");
frame1.setSize(200,150);
frame1.setLocation(200,100);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setVisible(true);
JFrame rx = new JFrame();
rx.setTitle("rx's Windows");
rx.setSize(300,300);
rx.setLocation(0,0);
rx.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
rx.setVisible(true);*/
/*String s = "Welcome to java";
String s1 = new String("Welcome to java");
String s2 = s1.intern();
String s3 = "Welcome to java";
System.out.println("s1 == s is" + (s1 == s));
System.out.println("s2 == s is" + (s2 == s));
System.out.println("s.intern() == s3.intern() is" + (s.intern() == s3.intern()));
String s4 = "Welcome";
String s5 = "j a v a";
System.out.println();
System.out.println(s4.toLowerCase());
System.out.println(s4.toUpperCase());
System.out.println(s5.trim());
System.out.println(s4.replace('e','A'));
System.out.println(s4.replaceAll("e","E"));*/
/*System.out.println("Welcome to java".indexOf('W'));
System.out.println("Welcome to java".indexOf('o'));
System.out.println("Welcome to java".indexOf('o',5));
System.out.println("Welcome to java".indexOf("come"));
System.out.println("Welcome to java".indexOf("java",5));
System.out.println("Welcome to java".indexOf("Java",5));
System.out.println("Welcome to java".lastIndexOf('W'));
System.out.println("Welcome to java".lastIndexOf('o'));
System.out.println("Welcome to java".lastIndexOf('o',5));
System.out.println("Welcome to java".lastIndexOf("come"));
System.out.println("Welcome to java".lastIndexOf("java",5));
System.out.println("Welcome to java".lastIndexOf("Java",5));*/
/*char[] chars = "Java".toCharArray();
getChars(int srcBegin,int
相关文档:
Java学习从入门到精通
一、 JDK (Java Development Kit)
JDK是整个Java的核心,包括了Java运行环境(Java Runtime Envirnment),一堆Java工具和Java基础的类库(rt.jar)。不论什么Java应用服务器实质都是内置了某个版本的JDK。因此掌握JDK是学好Java的第一步。最主流的J ......
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
//1.编写一个程序,该程序可读入一个外部文件,并将文件内容赋值给一个字符串
package Zhangyiwei
import java.io.*;
public class Zhangyiwei {
public static String filename = "c:\\1.txt";
public static void main(String[] args) throws FileNotFoundException, IO ......
importjava.text.DecimalFormat;
publicclassTestNumberFormat{
publicstaticvoidmain(String[]args){
doublepi=3.1415927; //圆周率
//取一位整数
System.out.println(newDecimalFormat("0").format(pi)); //3
//取一位整数和两位小数
System ......