20145235 The first experimental report on Java programming

Source: Internet
Author: User

Experiment a familiar experiment content of Java development environment

1. Compile and run a simple Java program using the JDK;

2. Edit, compile, run, and debug Java programs using Eclipse.

Experimental knowledge points

1.JVM, JRE, JDK installation location and difference;

2. command line run JAVAC;JAVA;JAVAC-CP; JAVA-CP;

The setting method and application of 3.path,classpath,sourcepath;

4. Package management: package;import;javac-d;

5.Eclipse (Netbeans) manages Java projects, debugging: Breakpoints, single step execution, etc.;

6.Java basic syntax: type and type conversion; variables; operators; Process control, etc.;

The use of 7.JDK help documents.

Experimental stepsone, the use of JDK compiled, run a simple Java program;

First, edit the environment variables to use Javac and Java in the JDK for flanging;

Javac is a compilation tool;

Java is a running tool;

Write a simple program with text;

The code is as follows:

The results of the operation are as follows:

second, the idea under the Java program development, debugging

To establish a new project;

Then create a new class;

Write code;

Run the program;

Third, practice the implementation of Caesar password

Component: Main function (choose encryption or decryption), decryption class, encryption class;

Code:

ImportJava.io.*;ImportJava.util.Scanner; Public classKaisa { Public Static voidMain (string[] args) {System.out.println ("Input" 1 "encryption; input" 2 "decryption"); Scanner C=NewScanner (system.in); intb =C.nextint (); if(b = = 1) {System.out.print ("Please enter the secret key:"); Scanner s=NewScanner (system.in); intA =S.nextint ();        C (a); } Else if(b = = 2) {System.out.print ("Please enter the secret key:"); Scanner s=NewScanner (system.in); intA =S.nextint ();        B (a); }    }     Public Static voidCintN) {Try {            Charb[]; BufferedReader Br2=NewBufferedReader (NewInputStreamReader (system.in)); System.out.println ("Please enter a clear text:"); String str2=Br2.readline (); b=Str2.tochararray (); System.out.println ("Ciphertext is:"); intK =N;  for(inti = 0; I < str2.length (); i++) {                CharCH = (Char) ((B[i]-' a ' + k)% + ' a ');            System.out.print (CH); } System.out.println ("Key k=" +k); } Catch(IOException e) {System.out.println (E.getmessage ()); }    }     Public Static voidBintm) {Try {            Charb[]; BufferedReader Br2=NewBufferedReader (NewInputStreamReader (system.in)); System.out.println ("Please enter a cipher:"); String str2=Br2.readline (); b=Str2.tochararray (); System.out.println ("Clear text is:"); intk=m;  for(intI=0;i<str2.length (); i++)            {                CharCh= (Char) ((b[i]-' a '-K)%26+ ' a ');            System.out.print (CH); } System.out.println ("Key k=" +k); }Catch(IOException e) {System.out.println (E.getmessage ()); }}}

Operation Result:

20145235 The first experimental report on Java programming

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.