摘要:
import java.util.Arrays;
public class JavaArray {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//创建一维数组:
int arr[] = new int[]{1,2,3,5,15};
int arr2[] = {23,12,6};
int day[] = new int[]{31,28,31,30,31,30,31,30,31,30,31,31};
for(int i=0;i12;i++)
{
System.out.println((i+1)+"月有"+day[i]+"天");
}
//二级数组:
//int a[][] = new int[2][];
//a[0] = new int[2];
//a[1] = new int[3];
int a[][] = new int[][] 阅读全文
posted @ 2010-08-25 21:44
叮当小马
阅读(186)
评论(0)
推荐(1)
摘要:
import java.util.Date;
public class JavaString {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//char to string
char a[] = {'g','o','o','d','.'};
String s = new String (a); //全部字符
System.out.println(s);
String ss = new String (a,2,2);//部分字符
System.out.println(ss);
//多个字符串连接
String s1 = new String ("Hello");
String s2 = new String ("World");
String sss = s1 + " "+ s2;
System.out.println(sss); 阅读全文
posted @ 2010-08-25 21:38
叮当小马
阅读(948)
评论(1)
推荐(0)
摘要:
public class GetIfElse {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//if语句
int x = 45;
int y = 12;
if(xy)
{
System.out.println("变量xy");
}
if(x30)
{
System.out.println("z30");
}else if(z10)
{
System.o 阅读全文
posted @ 2010-08-25 21:35
叮当小马
阅读(268)
评论(0)
推荐(0)
摘要:
public class MyNumber {
static String s1="您好。";
public static void main(String[] args) {
// TODO Auto-generated method stub
String s2 = "Java";
System.out.println(s1);
System.out.println(s2);
//byte short int long
byte mybyte = 124; //-128-127
short myshort = 32564; //-32768 - 32767
int myint=45784612;
long mylong = 46789451;
long result = mybyte + myshort +myint + mylong;
System.out.println("结果为:" + result);
// float double;
float f1 = 13.23f 阅读全文
posted @ 2010-08-25 21:32
叮当小马
阅读(502)
评论(0)
推荐(0)