Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : java

·¢ÏÖÒ»¸öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½

¸Õ¸Õ¿´µ½Ò»ÆªÎÄÕÂÌá³öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½£¬»ù±¾Òâ˼ÈçÏ£º
Çë¿´C++´úÂ룺
class Base
{
public:
 Base()
 {
  init(); 
 }
 virtual ~Base() {}
protected:
 int value;
 virtual void init() 
 { 
  value = 100;     
 }
};
class Derived : public Base
{
public:
 Derived()
 {
  init();
 }
protected:
 void init() 
 {
  cout << "value = " << value << endl;
  // ×öһЩ¶îÍâµÄ³õʼ»¯¹¤×÷ 
 }
};
int main(int argc, char* argv[])
{
 Base* pb;
 pb = new Derived();
 delete pb;
 return 0;
}
Ö´Ðнá¹ûÊÇ
value = 100
ÔÙ¿´java´úÂ룺
class Base
{
  public Base()
  {
    init();
  }
  protected int value;
  protected void init()
  {
         value = 100;  
  }
......

·¢ÏÖÒ»¸öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½

¸Õ¸Õ¿´µ½Ò»ÆªÎÄÕÂÌá³öc++¶à̬Óëjava¶à̬²»Í¬µÄµØ·½£¬»ù±¾Òâ˼ÈçÏ£º
Çë¿´C++´úÂ룺
class Base
{
public:
 Base()
 {
  init(); 
 }
 virtual ~Base() {}
protected:
 int value;
 virtual void init() 
 { 
  value = 100;     
 }
};
class Derived : public Base
{
public:
 Derived()
 {
  init();
 }
protected:
 void init() 
 {
  cout << "value = " << value << endl;
  // ×öһЩ¶îÍâµÄ³õʼ»¯¹¤×÷ 
 }
};
int main(int argc, char* argv[])
{
 Base* pb;
 pb = new Derived();
 delete pb;
 return 0;
}
Ö´Ðнá¹ûÊÇ
value = 100
ÔÙ¿´java´úÂ룺
class Base
{
  public Base()
  {
    init();
  }
  protected int value;
  protected void init()
  {
         value = 100;  
  }
......

Java¸ß¼¶ÌØÐÔ 1

1.¾²Ì¬µ¼È룺
¾²Ì¬µ¼ÈëÊÇJDK1.5ºóмӵŦÄÜ£¬Ò»°ã²»Ôõô³£Ó㬺ܼòµ¥¸øÄã¾Ù¸öÀý×ÓÄã¾ÍÄÜÃ÷°×ÁË£¬¿´Õâ¶Î´úÂ룺
import static java.lang.System.out;//µ¼Èëjava.lang°üϵÄSystemÀàµÄ¾²Ì¬·½·¨out;
public class HelloWorld{
public static void main(String[] args){
out.print("Hello World!");//¼ÈÊÇÔÚÕâÀï²»ÓÃÔÙд³ÉSystem.out.println("Hello World!")ÁË£¬ÒòΪÒѾ­µ¼ÈëÁËÕâ¸ö¾²Ì¬·½·¨out¡£
}
}
import xxxx ºÍ import static xxxxµÄÇø±ðÊÇÇ°ÕßÒ»°ãµ¼ÈëµÄÊÇÀàÎļþÈçimport java.util.Scanner;ºóÕßÒ»°ãÊǵ¼È뾲̬µÄ·½·¨£¬import static java.lang.System.out;
¾²Ì¬µ¼ÈëÖ÷ÒªÊÇÖ¸¿ÉÒÔͨ¹ý¾²Ì¬µ¼ÈëÒ»¸öÀàµÄ·½·¨£¬¾Í¿ÉÒÔÔÚÒÔºóֻҪд·½·¨µÄÃû×־ͿÉÒÔ£¬²»ÓÃÁ¬ÀàµÄÃû×ÖҲдÁË¡£Ö÷ÒªÊʺÏÔÚ±à³ÌÖÐʹÓÃÂʺܸߵĺ¯Êý£¬Ê¹ÓÃÂʱȽϵ͵ĺ¯ÊýÕâÑù×öÏà·´ÓÐЩÂé·³ÁË¡£ÎÒ¾õµÃÕâÒ²ËãÊÇÒ»¸öС¼¼ÇÉ°ÕÁË¡£
2.¿É±ä²ÎÊýÓëforÑ­»·ÔöÇ¿£º
Õâ¸öÊÇÒ»°ãµÄÓ÷¨£º
public static void loop(String[] args){
for(int i=0;i<args.length;i++)
  {
   System.out.println(args[i]);
  }
}
  Õâ¸öÊÇJDK Ôö¼ÓµÄÐÂÌØÐÔµÄÓ÷¨£¡ ......

·¢ÏÖJavaÐéÄâ»úÄÚ´æй¶ÎÊÌâ

¡¾IT168 Îĵµ
¡¿ÄÚ´æ
й¶ÎÊÌâ¶ÔÓÚ³ÌÐòÀ´Ëµ£¬ÊÇÒ»¸öºÜÄÑ·¢ÏÖ£¬²¢ÇÒÈÝÒ×ÒýÆðÑÏÖØÔÖº¦µÄÊÂÇé¡£
JavaÒ»Ö±ÒÔÆäÀ¬»ø»ØÊÕ»úÖÆΪ×ÔºÀ£¬ÄÇÊÇ·ñÕâÖÖ»úÖƾÍÊÇÍêÃÀµÄÄØ¡£
¡¡¡¡³£¹æÀí½âÉÏ£¬JavaµÄÄÚ´æ
¹ÜÀí»úÖÆÊǽ«¾Ö²¿±äÁ¿±£´æÔÚ¶ÑÖУ¬µ±±äÁ¿µÄ×÷ÓÃÓò½áÊøÖ®ºó£¬¸Ã±äÁ¿ËùÕ¼ÓõÄ
ÄÚÈݻᱻ×Ô¶¯»ØÊÕ¡£²»ÐèÒª×öÈκÎÌØÊâµÄ´¦Àí¡£±ÈÈçÏÂÃæµÄ´úÂ룺
#div_code img{border:0px;}
public

class
JavaMemory{
      
private

final

int
dataSize
=
(
int
) (Runtime.getRuntime().maxMemory()
*

0.6
);      
public

void
f(){
          {
              
byte
[] data1
=

new

byte
[dataSize];
         }
          
byte
[] data2
=

new

byte
[dataSize];
      }

   &n ......

·ÖÒ³¹¦ÄܵÄjavaʵÏÖ

       ×î½ü×öÒ»¸öÏîÄ¿£¬ÒªÓõ½·ÖÒ³¹¦ÄÜ£¬²Î¿¼Á˺ܶ෽·¨£¬ÓеIJ»ºÏÊÊ£¬ÓеIJ»Ï²»¶£¬ÓÚÊÇ×Ô¼ºÔÚËûÃǵĻù´¡ÉÏÕûÁËÒ»¸ö£»Ë¼Â·ÊÇÕâÑùµÄ£ºÏÈ°ÑÐèÒª·ÖÒ³µÄÊý¾Ý»òÊǼǼ¶¼²éѯ³öÀ´ ´æÈëÒ»¸ö¼¯ºÏÀàÀïÈçList»òÊÇVector£¬È»ºóÀûÓÃÆäsublist(int findex,int eindex)·½·¨£¬»ñÈ¡ÐèÒª·ÖÒ³µÄÊý¾Ý»ò¼Ç¼,¹ØÓÚsublist()º¯Êý¾Í×Ô¼ºÈ¥²éAPIÁË¡£ÏÂÃæÌùÏ´úÂë°É£¬Ê×ÏÈÊǽ«·ÖÒ³ËùÐèµÄһЩ¸ö¶«¶«³éÏó³öÒ»¸öjavabean¶ÔÏó—PageBean:
public class PageBean {
private int curPage; //µ±Ç°Ò³
private int pageCount; //×ÜÒ³Êý
private int rowsCount; //×ÜÐÐÊý
private int pageSize=10; //ÿҳ¶àÉÙÐÐ



public PageBean(int rows){

this.setRowsCount(rows);
if(this.rowsCount % this.pageSize == 0){
this.pageCount=this.rowsCount / this.pageSize;
}
else if(rows<this.pageSize){
this.pageCount=1;
}
else{
this.pageCount=this.rowsCount / this.pageSize +1;
}
}


public int getCurPage() {
return curPage;
}
public void setCurP ......

JNI¼¼ÊõʵÏÖJAVA³ÌÐòµ÷ÓÃdll


JAVAµÄ¿çƽ̨µÄÌØÐÔÉîÊÜjava³ÌÐòÔ±ÃǵÄϲ°®,µ«ÕýÊÇÓÉÓÚËüΪÁËʵÏÖ¿çƽ̨µÄÄ¿µÄ,ʹµÃËüºÍ±¾µØ»úÆ÷µÄ¸÷ÖÖÄÚ²¿ÁªÏµ±äµÃºÜÉÙ,´ó´óÔ¼ÊøÁËËüµÄ¹¦ÄÜ,±ÈÈçÓëһЩӲ¼þÉ豸ͨÐÅ,ÍùÍùÒª»¨·ÑºÜ´óµÄ¾«Á¦È¥Éè¼ÆÁ÷³Ì±àд´úÂëÈ¥¹ÜÀíÉ豸¶Ë¿Ú,¶øÇÒÓÐһЩÉ豸³§ÉÌÌṩµÄÓ²¼þ½Ó¿ÚÒѾ­¾­¹ýÒ»¶¨µÄ·â×°ºÍ´¦Àí,²»ÄÜÖ±½ÓʹÓÃjava³ÌÐòͨ¹ý¶Ë¿ÚºÍÉ豸ͨÐÅ,ÕâÖÖÇé¿öϾ͵ÿ¼ÂÇʹÓÃjava³ÌÐòÈ¥µ÷ÓñȽÏÉó¤Í¬ÏµÍ³´ò½»µÀµÄµÚÈý·½³ÌÐò,´Ó1.1°æ±¾¿ªÊ¼µÄJDKÌṩÁ˽â¾öÕâ¸öÎÊÌâµÄ¼¼Êõ±ê×¼:JNI¼¼Êõ.
       JNIÊÇJava Native Interface(Java±¾µØ½Ó¿Ú)µÄËõд,±¾µØÊÇÏà¶ÔÓÚjava³ÌÐòÀ´ËµµÄ,Ö¸Ö±½ÓÔËÐÐÔÚ²Ù×÷ϵͳ֮ÉÏ,Óë²Ù×÷ϵͳֱ½Ó½»»¥µÄ³ÌÐò.´Ó1.1°æ±¾µÄJDK¿ªÊ¼,JNI¾Í×÷Ϊ±ê׼ƽ̨µÄÒ»²¿·Ö·¢ÐÐ.ÔÚJNI³öÏֵijõÆÚÊÇΪÁËJava³ÌÐòÓë±¾µØÒѱàÒëÓïÑÔ,ÓÈÆäÊÇCºÍC++µÄ»¥²Ù×÷¶øÉè¼ÆµÄ,ºóÀ´¾­¹ýÀ©Õ¹Ò²¿ÉÒÔÓëcºÍc++Ö®ÍâµÄÓïÑÔ±àдµÄ³ÌÐò½»»¥,ÀýÈçDelphi³ÌÐò.
       ʹÓÃJNI¼¼Êõ¹ÌÈ»ÔöÇ¿ÁËjava³ÌÐòµÄÐÔÄܺ͹¦ÄÜ,µ«ÊÇËüÒ²ÆÆ»µÁËjavaµÄ¿çƽ̨µÄÓŵã,Ó°Ïì³ÌÐòµÄ¿ÉÒÆÖ²ÐԺͰ²È«ÐÔ,ÀýÈçÓÉÓÚÆäËûÓïÑÔ(ÈçC/C++)¿ÉÄÜÄܹ»ËæÒâµØ·ÖÅä¶ÔÏó/Õ¼ÓÃÄÚ´æ,JavaµÄÖ¸Õ밲ȫÐԵò ......

ÓйØjavaÖеÄString£¬StringBuffer£¬StringBuild

String ×Ö·û´®³£Á¿
StringBuffer ×Ö·û´®±äÁ¿£¨Ḭ̈߳²È«£©
StringBuilder ×Ö·û´®±äÁ¿£¨·ÇḬ̈߳²È«£©
¼òÒªµÄ˵£¬ String ÀàÐÍºÍ StringBuffer ÀàÐ͵ÄÖ÷ÒªÐÔÄÜÇø±ðÆäʵÔÚÓÚ String ÊDz»¿É±äµÄ¶ÔÏó, Òò´ËÔÚÿ´Î¶Ô String ÀàÐͽøÐиıäµÄʱºòÆäʵ¶¼µÈͬÓÚÉú³ÉÁËÒ»¸öÐ嵀 String ¶ÔÏó£¬È»ºó½«Ö¸ÕëÖ¸ÏòÐ嵀 String ¶ÔÏó£¬ËùÒÔ¾­³£¸Ä±äÄÚÈݵÄ×Ö·û´®×îºÃ²»ÒªÓà String £¬ÒòΪÿ´ÎÉú³É¶ÔÏ󶼻á¶ÔϵͳÐÔÄܲúÉúÓ°Ï죬Ìرðµ±ÄÚ´æÖÐÎÞÒýÓöÔÏó¶àÁËÒÔºó£¬ JVM µÄ GC ¾Í»á¿ªÊ¼¹¤×÷£¬ÄÇËÙ¶ÈÊÇÒ»¶¨»áÏ൱ÂýµÄ¡£
¶øÈç¹ûÊÇʹÓà StringBuffer ÀàÔò½á¹û¾Í²»Ò»ÑùÁË£¬Ã¿´Î½á¹û¶¼»á¶Ô StringBuffer ¶ÔÏó±¾Éí½øÐвÙ×÷£¬¶ø²»ÊÇÉú³ÉеĶÔÏó£¬Ôٸıä¶ÔÏóÒýÓá£ËùÒÔÔÚÒ»°ãÇé¿öÏÂÎÒÃÇÍƼöʹÓà StringBuffer £¬ÌرðÊÇ×Ö·û´®¶ÔÏó¾­³£¸Ä±äµÄÇé¿öÏ¡£¶øÔÚijЩÌرðÇé¿öÏ£¬ String ¶ÔÏóµÄ×Ö·û´®Æ´½ÓÆäʵÊDZ» JVM ½âÊͳÉÁË StringBuffer ¶ÔÏóµÄÆ´½Ó£¬ËùÒÔÕâЩʱºò String ¶ÔÏóµÄËٶȲ¢²»»á±È StringBuffer ¶ÔÏóÂý£¬¶øÌرðÊÇÒÔϵÄ×Ö·û´®¶ÔÏóÉú³ÉÖУ¬ String ЧÂÊÊÇÔ¶Òª±È StringBuffer ¿ìµÄ£º
String S1 = “This is only a” + “ simple” + “ test”;
StringBuffer Sb = n ......
×ܼǼÊý:6386; ×ÜÒ³Êý:1065; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [1] [2] [3] 4 [5] [6] [7] [8] [9] [10]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ