Java beginners (for general basic questions, refer to here)

Source: Internet
Author: User
Helloworld
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 84
Path and classpath
1. What are Java path and classpath?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 904
2. How to add all. Jar files in a directory to classpath at a time?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 905
3. What is the default value of classspath?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 906
4. How to Find the class required for running the program?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 907
5. How is path and classpath set in Linux?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 908
6. How to modify path and classpath?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 909

Java help and API documentation
1. What is Java API reference?
The API is in HTML format. You can find a package on Sun's website.
This includes api reference and user guide, which are easy to find in. chm format.
API reference is a required document generated by Java SDK.
2. Where is the source code of the Java basic class library?
The JDK installation directory has the source code src.zip.
3. What is Java Web Start?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 911

Development Environment
1. What is the difference between lib under JRE and Lib under JDK?
JRE is a subset of JDK. Provides a runtime environment. The JDK lib directory is used by JDK. For example, if JDK has some tools, files in this directory may be used. For example, a compiler. The lib directory of JRE is JVM and used during runtime. Including all standard classes and extensions
2. My JBuilder cursor is not aligned?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 913
3. What if JDK version conflict occurs?
To determine which JDK (Win2000) Windows is used, modify the registry:
HKEY_LOCAL_MACHINE \ SOFTWARE \ kerberoft \ Java Development Kit \ CurrentVersion
To determine which JDK JBuilder can be set in project properties.
4. Can editplus compile Java? How to Set it?
First, install and debug the Java Runtime Environment.
First, go to "Tools"> "Configure user tools.
Expand the "Tools" tree menu in the category-> "user tools", select "group 1" in "group and Tool project", and click "group name" on the right of the panel... "button to change the text" group1 "to" compile Java program ".
Then, select the modified Group "compile Java program", click "Add new tool", select a program, create a new program, and select it.
Next is the most important step (modifying attributes ):
1.1 add compilation function
Change the content in "menu text" to "javac ";
"Command": select the Compiling Program javac in the bin directory after JDK installation. EXE. If the JDK installation path is "C: \ JDK", the path is "C: \ JDK \ bin \ javac.exe ";
Select "file name" for "parameter", that is, "$ (filename )";
Select "file directory" as "$ (filedir)" for "Initial directory )";
Select the capture output check box.
1.2 add execution function
Change the content in "menu text" to "Java ";
"Command": select the compiled program java. EXE in the bin directory after JDK installation, and the path is "C: \ JDK \ bin \ java.exe ";
Select "File Name (not including the extension)" for "parameter", that is, "$ (filenamenoext )";
Select "file directory" as "$ (filedir)" for "Initial directory )";
Select the capture output check box.
This completes the basic configuration.

Basic Concepts
1. Public, private, and protect access mechanisms

Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 914
2. How to define a constant in Java?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 915
3. What is the difference between the exception throw and throws?
Throw throws an exception in the program, while throws declares that an exception is thrown in the method declaration.
4. What does upcasting mean?
Upcasting is the upstream. that is to say, treat a subclass as its parent class, for example, for the method Void Do (Object OBJ ){...}, you can call any object as a parameter.

Compile and run
1. How to compile multiple. Java source files into A. class?
Java-D. A. Java B. Java
2. What does depreciated API mean?
Java is developing too fast, so you should try to use the latest API, but the old API is still compatible, so back to waning your deprecated API
3. How to compile all the java files in a directory?
Ant or JBuilder, or write the script by yourself.
4. How can I avoid dos windows during program execution?
Javaw
5. How to run the JAR file?
Java-jar ***. Jar
6. How to remove Java memory restrictions
Add the-xmx parameter to set the maximum Java heap size, for example, Java-xms10m myclass.
7. What is a Java obfuscation compiler?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 916
8. How to locally compile a Java application into an EXE?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 917
9. Jar command?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 918

Data Type and conversion
1. How do int, Char, double, and byte convert each other?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 919
2.int and byte array Conversion Program?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 920
3. Conversion between string and Int?
A1 = integer. parseint (S1 );
S1 = integer. tostring (A1 );
4. How does Java obtain random integers?
First, use random () to obtain a random floating point number, and then multiply it by the expected integer.
And then the final result is rounded up.
5. How to convert the string type to a hexadecimal integer?
Public static void main (string ARGs []) {
String x = "0x300c8 ";
Int y = integer. Decode (x). intvalue ();
System. Out. println (y );
}
6.int and Java. Lang. Integer are different?
Int Is a data type, and integer is a class integer with more powerful functions. It can be used to convert integers into floating-point numbers. You can use integer Constructor Integer (INT) to create an object for an integer. Similar classes include float, short, long, etc.

Data Structure
1. How to implement two-dimensional vectors?
Vector vector1 = new vector ();
Vector vector2 = new vector ();
...
..
Hashtable numbers = new hashtable ();
Numbers. Put ("vector1", vector1 );
Numbers. Put ("vector2", vector2 );
2. How can I get the current system time in Java?
For example, the current date, date today = new date (system. currenttimemillis ());
3. How to convert java. util. date to Java. SQL. Date?
Conversion:

Java. SQL. Date SD;
Java. util. Date UD;
// Initialize the UD such as UD = new java. util. Date ();

SD = new java. SQL. Date (ud. gettime ());

If you want to insert data to the database and the corresponding field is of the date type
You can use the preparedstatement. setdate (INT, java. SQL. Date) method.
The Java. SQL. date can be obtained using the above method.

You can also use the database to provide the to_date function.
For example, the existing ud
To_date (New simpledateformat (). Format (UD, "yyyy-mm-dd hh: mm: SS "),
"YYYY-MM-DD hh24: MI: SS ")
Note that the representation format in Java is different from the format provided by the database.

System Problems
1. How to start a program in Java?
String strcommand;
String cmd = "cmd ";
If (! System. getproperty ("OS. Name"). Equals ("Windows NT") cmd = "command ";
Cmd = cmd + "/C" + strcommand;
Try {
Runtime.getruntime(cmd.exe C (CMD );
}
Catch (ioexception ex ){
}

Strcommand is a command string. How can I use it under DOS? How can I use it here?
2. How to obtain the application path
Properties system. getproperties () contains
3. How to get the current system time?
1. simpledateformat formatter = new simpledateformat ("yyyy-mm-dd ");
String time = formatter. Format (new date ());
2. Calendar Cal = calendar. getinstance ();
Int year = Cal. Get (calendar. year );
Month =... and so on

Input and Output
1. Can I write a program in Java only to access the serial port?
Sun provides a package named javax. Comm, which is used to perform the * operation on the serial port.
2. Differences between writeutf and write
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 921
3. How to Use filewriter to wrap a line in the text?
\ R \ n

Network Problems
1. How can I allow my program to access the external network through proxy?
System. setproperty ("Java. proxyhost", "your proxy here ");

Local problems
1. How to call a local DLL?
JNI
2. How to Write a scanner program in Java?
Http://www.matrix.org.cn/forum_view.asp? Forum_id = 19 & view_id = 2741

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.