Skip to main content

Posts

Showing posts from February, 2009

Comparison == vs equals() in Java

In java, we have two operations (" == " and " equals() ") to check the equivalence of String s. It is important to understand that the difference between them.    == The == operator compares the two objects and checks to see if two objects are exactly the same object (refer to the same instance). .equals() The equals() method compares the characters in the two different objects. Two strings may be different objects , but can contains the same values (exactly the same characters). public class Main {     public static void main(String[] args) {         String s1 = "Shangshu";         String s2 = new String(s1);         System.out.println(s1 + " == " + s2 + " is " + (s1 == s2));         System.out.println(s1 + ".equals(" + s2 + ") is " + (s1.equals(s2)));     } } The output of the above code is: Shangshu == Shangshu is false Shangshu.equals(Shangshu) is true However, please compare the following cod

Using String Table in VC

String table is a very useful resource for localization. The usage is simple: Add a string to the string table: // ID VALUE Caption IDS_STRING 58624(auto) String Table Test In the file, CString::LoadString() function can help you load the string from string table CString str; str.LoadString(IDS_STRING);

Create Splitting Windows in VC 2005

Add two CSplitterWnd type variables into the MainFrame: CSplitterWnd m_wndSplitterLM; // split the window to left and middle panel // Than add the following code into the OnCreateClient Function: BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext) { // create a splitter with 1 row, 2 columns if (!m_wndSplitterLM.CreateStatic(this, 1, 2)) { TRACE("SpltLR create failed\n"); return false; } // add the first splitter pane - the default view in column 0 if (!m_wndSplitterLM.CreateView(0, 0, RUNTIME_CLASS(CMultiLayerTree), CSize(60, 0), pContext)) { TRACE0("Failed to create first pane\n"); return FALSE; } // add the second splitter pane - which splits the right window into two columns if (!m_wndSplitterMR.CreateStatic( &m_wndSplitterLM, // our parent window is the first splitter 1, 2, // the new splitter is 1

Web服务器的架设 (1)

1. Install Webserver: sudo apt-get install apache2 2. Install Database Server sudo apt-get install mysql-server-5.0 Typing the password for Mysql server and keep it in mind. 3. Install PHP5 and Apache PHP5 module sudo apt-get install php5 libapache2-mod-php5

Enable root Account in Ubuntu Server

After ubuntu server has been installed, you can login with the account that you created. Then the following command can enable you create a password for root. test@test: sudo passwd root And then input your passwd for root. Command "su" can let you access the root, just type: test@test: su Be sure that remember the passwd for root for security reasons.