您正在查看 "java学习笔记" 分类下的文章 2010-03-04 13:45 package mypackage;
import java.io.*;
import java.util.*;
import java.text.*;
public class DataComparison
{
public static void main(String[]args) throws FileNotFoundException, IOException
{
String courseId1;
String courseId2;
int numberOfCourses;
DoubleClass avg1 = new DoubleClass();
DoubleClass avg2 = new DoubleClass();
|
2010-03-03 19:47
public class RadixSort
{
public static void sort(int[] number,int d)
{
int k=0;
int n=1;
int[][] temp = new int[number.length][number.length];
int[] order=new int[number.length];
while(n<=d)
{
for (int i=0; i<number.length; i++)
{
int isd = ((number[i]/n)%10);
|
2010-03-03 13:06 利用图形用户界面(GUI)进行输入/输出;
java提供了JOptionPane类,以便让编程人员可以利用GUI组件进行I/O操作,
JOptionPane类包含在javax.swing数据包中, showInputDialog方法允许用户从键盘输入字符串,而showMessageDialog 方法允许编程人员显示结果。
使用showInputDialog方法的语法如下:
str = JOptionPane.showInputDialog(stringExpresson);
示例:(圆的面积和周长)
编程示例:斐波纳契数列
package mypackage;
import javax.swing.JOptionPane;
public c |
2010-03-01 16:12
public class SeqStack implements Stack //建立堆栈类
{
final int defaultSize = 10;
int top;
Object [] stack;
int maxStackSize;
public SeqStack()
{
initiate(defaultSize);
}
private void initiate(int sz)
{
maxStackSize = sz;
top = 0;
stack = new Object[sz];
}
public void push(Object obj) throws Exception
{
if(top == maxStackSize)
|
2010-03-01 10:58 import java.util.Arrays;
public class Testing
{
public static void main(String [] args)
{
char [] a = new char [64];
Arrays.fill(a, 'H');
String s = new String(a);
System.out.println("s = \"" + s + "\"");
Object[] objects = new Object[8];
Arrays.fill(objects,2,5,"Java");
System.out.println("objects =
|
2010-03-01 10:17 数组是一个对象,数组复制可以调用Object.clone()方法来对它进行复制
public class Ex022
{
public static void main(String [] args)
{
int[] a = {22, 44, 66, 88};
print(a);
int[] b = (int [])a.clone(); //数组复制
print(b);
String []c = {"AB", "CD", "EF"};
print(c);
String [] d =(String [])c.clone();
print
|
2010-02-02 16:16 今天学了一些java中的string用法。归类一下:
code1:
public class StringDemo
{
public static void main(String[] args)
{
String text = "hello";
System.out.println("字符串内容:" + text);
System.out.println("字符串长度:" + text.length());
System.out.println("等于 hello? " + text.equals("hello"));
System.out.println("转为大写: |
2010-01-25 13:30 class Xu
{
public static void main(String argc[])
{
String[] names = {"jekey","sawpad","lopp"};
int result = max(1, 2, -1, 3, 4, 5, 2, 3, 18, 6, 7); //result = maxvalue
System.out.println("result="+result);
printString(names);
|
| | |