javaºÍC++µÄÓï·¨Çø±ð—1
C++ÓëJavaµÄÓï·¨Çø±ð
Ê×ÏÈ£¬Á½¸ö´óµÄ²»Í¬ÊÇÖ÷º¯ÊýºÍÔõÑù±àÒëµÄ²»Í¬£¬½ÓÏÂÀ´ÊÇÐí¶àСµÄÇø±ð¡£
main º¯Êý
C++
//×ÔÓɸ¡¶¯µÄº¯Êý
int main( int argc, char* argv[])
{
printf( "Hello, world" );
}
Java
// ÿ¸öº¯Êý¶¼±ØÐëÊÇÒ»¸öÀàµÄÒ»²¿·Ö;µ±java <class>ÔËÐÐÊÇÒ»¸öÌØ¶¨ÀàµÄÖ÷º¯Êý»á±»µ÷ÓÃ
// (Òò´ËÄã¿ÉÒÔÈÃÿ¸öÀà¶¼ÓÐÒ»¸ömainº¯Êý£¬ÕâÔÚдµ¥Ôª²âÊÔÊǺÜÓÐÓÃ)
class HelloWorld
{
public static void main(String args[])
{
System.out.println( "Hello, World" );
}
}
ÀàµÄÉùÃ÷
³ýÁË Java ²»ÒªÇóÓ÷ֺÅÍ⼸ºõÊÇÏàͬµÄ¡£
C++
class Bar {};
Java
class Bar {}
·½·¨ÉùÃ÷
¶¼ÏàͬµÄ, ³ýÁËÔÚJava,·½·¨±ØÐë×ÜÊÇij¸öÀàµÄÒ»²¿·Ö²¢ÇÒ¿ÉÄÜpublic/private/protected ×÷ΪÐÞÊÎ
¹¹Ô캯ÊýºÍÎö¹¹º¯Êý
¹¹Ô캯Êý¶¼ÊÇÏàͬµÄ (¼´ÀàµÄÃû×Ö), JavaûÓÐ׼ȷÒâÒåÉϵĵÄÎö¹¹º¯Êý
¾²Ì¬³ÉÔ±º¯ÊýºÍ±äÁ¿
·½·¨ÉùÃ÷ÊÇÏàͬµÄ, µ« Java Ìṩ¾²Ì¬³õʼ»¯¿éÀ´À´³õʼ»¯¾²Ì¬±äÁ¿ (²»ÐèÒªÔÚÔ´ÎļþÖÐÉùÃ÷):
class Foo
{
static private int x;
// ¾²Ì¬³õʼ»¯¿é
{ x = 5; }
}
¶ÔÏóµÄÉùÃ÷
C++
// ÔÚÕ»ÖÐ
myClass x;
//»òÕßÔÚ¶ÑÖÐ
myClass *x = new myClass;
Java
// ×ÜÊÇÔÚ¶Ô¶ÑÖÐÉùÃ÷
myClass x = new myClass();
¼Ì ³Ð
C++
class Foo : public Bar
{ ... };
Java
class Foo extends Bar
{ ... }
·ÃÎʼ¶±ð (abstraction barriers)
C++
public:
void foo();
void bar();
Java
public void foo();
public void bar();
Ð麯Êý
C++
 
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
Javaƽ̨ÌṩÁËÒ»¸öÈ«Ðµļ¯ºÏ¿ò¼Ü¡£“¼¯ºÏ¿ò¼Ü”Ö÷ÒªÓÉÒ»×éÓÃÀ´²Ù×÷¶ÔÏóµÄ½Ó¿Ú×é³É¡£²»Í¬½Ó¿ÚÃèÊöÒ»×鲻ͬÊý¾ÝÀàÐÍ¡£
Java 2¼¯ºÏ¿ò¼Üͼ
¼¯ºÏ½Ó¿Ú£º6¸ö½Ó¿Ú£¨¶ÌÐéÏß±íʾ£©£¬±íʾ²»Í¬¼¯ºÏÀàÐÍ£¬ÊǼ¯ºÏ¿ò¼ÜµÄ»ù´¡¡£
³éÏóÀࣺ5¸ö³éÏóÀࣨ³¤ÐéÏß±íʾ£©£¬¶Ô¼¯ºÏ½Ó¿ÚµÄ²¿·ÖʵÏÖ¡£¿ÉÀ©Õ¹Îª×Ô¶¨Ò弯ºÏÀà¡£
......
ÏñÒÆ¶¯Íø¹ØÒ»Ñù£¬iisforwardÕâ¸öISAPI¹ýÂËÆ÷Ò²»á¶Ôrequest¶ÔÏó½øÐÐÔÙ°ü×°£¬¸½¼ÓһЩWLSÒªÓõÄÍ·ÐÅÏ¢¡£ÕâÖÖÇé¿öÏ£¬Ö±½ÓÓÃrequest.getRemoteAddr()ÊÇÎÞ·¨È¡µ½ÕæÕýµÄ¿Í»§IPµÄ¡£
ʵ¼ÊµÄiisforward¸½¼ÓÍ·ÈçÏ£º
WL-Proxy-Client-IP=211.161.1.239
Proxy-Client-IP=211.161.1.239
X-Forwarded-For=211.161.1.239
WL- ......
import java.io.*;
class FileTest
{
public static void main(String[] args) throws Exception
{
//File f=new File("1.txt");
//f.createNewFile();
//f.mkdir();
//File f=new File("E:\\JavaLesson\\Lesson7\\1.txt");//ÔÚWindowsϵͳÏÂ,Óþø¶Ô ......
½â¾öÕ»ºÍ¶ÑÄÚ´æÒç³ö°ì·¨ÒªÉèÖû·¾³ÄÚ´æ±äÁ¿£º
1¡¢ÔÚÔËÐнçÃæ£¨cmd½øÈ룩ÖÐÔËÐÐÃüÁjava -Xms256m -Xmx1024m£¬Î¬»¤ÉÏÏÂÏÞÄÚ´æ²ÎÊý£¬×î´óÄÚ´æ²»ÄÜ´í¹ýϵͳÄÚ´æµÄ1/4£¬×îСÄÚ´æ²»ÄÜСÓÚ×î´óÄÚ´æµÄ1/4
2¡¢ÔÚTommcat /bin·¾¶Ï£¬Èç¹ûÊǰ²×°°æÐèÒªservice.batÎļþ,´ËÎļþÔÚ½âѹËõ°æÀï¡£
3¡¢ ÔÚÔËÐнçÃæ£¨cmd½øÈ룩ÖÐ
......