Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

java ÈÕÆÚ¼ÆËã(¼¸ÌìÇ°ºó)

public class DateTest {
 public static void main(String[] args) {
  Date date = new Date(); // н¨Ò»¸öÈÕÆÚ
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); // ¸ñʽ»¯ÈÕÆÚ
  String beforeDate = sdf.format(getDateBefore(date, 10));
  System.out.println(beforeDate);
  String afterDate = sdf.format(getDateAfter(date, 10));
  System.out.println(afterDate);
 }
 /**
  * µÃµ½¼¸ÌìÇ°µÄʱ¼ä
  */
 public static Date getDateBefore(Date d, int day) {
  Calendar now = Calendar.getInstance();
  now.setTime(d);
  now.set(Calendar.DATE, now.get(Calendar.DATE) - day);
  return now.getTime();
 }
 /**
  * µÃµ½¼¸ÌìºóµÄʱ¼ä
  */
 
 public static Date getDateAfter(Date d, int day) {
  Calendar now = Calendar.getInstance();
  now.setTime(d);
  now.set(Calendar.DATE, now.get(Calendar.DATE) + day);
  return now.getTime();
 }
}


Ïà¹ØÎĵµ£º

ѧϰJavaÀàµÄÊôÐÔ

ѧϰJavaÀàµÄÊôÐÔ-Î人±±´óÇàÄñ
¡¡¡¡Public¡¢private¡¢protectedÏÔʾÁËÈýÖÖÀàÖеÄÊôÐԺͷþÎñµÄÀàÐÍ£¬publicÊÇ¿ÉÒÔËæÒâ·ÃÎʵġ¢privateÊÇÍâ½ç²»ÄÜ·ÃÎʵÄ(ÏÔʾÁËÊý¾ÝµÄ·â×°ÐÔ)¡¢protected˵Ã÷Êý¾ÝÊÇÊܱ£»¤µÄ¡£ÏÂÃæ¾ÍÀ´Ïêϸ½²ÊöÒ»ÏÂÕâÈý¸ö¾¿¾¹ÓÐʲôÇø±ð¡£
¡¡¡¡Ê×ÏÈÒªÁ˽âһϰüµÄ¸ÅÄî¡£ÓÐÈô¸É¸öÀ࣬ËüÃÇÏ໥֮¼äÓÐÒ»¶¨µÄ¹ØÏ ......

JavaÉè¼Æģʽ֮State(״̬ģʽ)

¶¨Ò壺
GOF¡¶Éè¼Æģʽ¡·Öиø״̬ģʽϵĶ¨ÒåΪ£ºÔÊÐíÒ»¸ö¶ÔÏóÔÚÆäÄÚ²¿×´Ì¬¸Ä±äʱ¸Ä±äËüµÄÐÐΪ¡£
ÏÈ¿´Ò»¸öÀý×Ó£º
package com.state;
public class KissingPrincess {
// ±ê־룬±êÖ¾ÊÇÇàÍÜ»¹ÊÇÍõ×Ó¡£
private boolean isFrog = true;
// ¸ù¾ÝisFrog½øÐв»Í¬µÄ²Ù×÷¡£
public void greet() {
if (isFrog)
......

javaÀàÐÍת»»×ܽá

ÀàÐÍת»»×ܽ᣺
1.Ô­ÐÍÊý¾Ýbyte,short,int,long,float,double,char,boolean,СÀàÐÍÊý¾Ý¿ÉÒÔÖ±½Ó¸³¸ø´óÀàÐÍÊý¾ÝÀýÈç
 int a=1;byte b=2;short c=3;float d=3;double e=4;char f='a';boolean g=true;long l=10;
c=b;
a=f;
d=a;
e=d;
byteÐÍÊý¾Ý²»ÄÜÖ±½Ó¸³¸øcharÐÍÊý¾Ý£¬ÒòΪbyte±íʾµÄÊÇ8λÓзûºÅÊý£¬¶øchar±íʾµ ......

java ·ÖÆ»¹û

ÓÐ600¸öÆ»¹û£¬10¸öºÐ×Ó£¬ÒªÇó°Ñ600¸öÆ»¹û·Ö×°µ½10¸öºÐ×ÓÀï¡£Èç¹ûÓÐÈËÀ´ÂòÆ»¹ûËæ±ã˵³öÒ»¸öÊý£¬Ö±½ÓÄÃÕâЩºÐ×Ó×éװһϾͿÉÒÔ¸øËû²»Óòð·ÖºÐ×Ó¡£ÇëÎÊÕâ10¸öºÐ×ÓÓ¦¸Ã·Ö±ð×°¶àÉÙÆ»¹û£¿
´úÂëÈçÏÂ
import java.util.Scanner;
public class Test {
 public static void main(String[] args) {
  int box[] = ......

java×Ö·û´®´¦ÀíÀà

×Ô¼ºÊÕ¼¯µÄһЩjava´¦ÀíÀ࣬¹©ÒÔºó²éѯ
package com.tools;
import java.text.SimpleDateFormat;
import java.util.Date;
public class StringHandler {

/******************************
* ¹¦ÄÜ£º½«IPµØַת»»Îª¶ÔÓ¦µÄÕûÊý
* ·µ»ØÀàÐÍ£ºlong
******************************/
public static long getI ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ