2020.10.03

一、今日学习内容

  InputTest.java

package ceshi;
import java.util.*;

public class InputTest
{  
   public static void main(String[] args)
   {  
      Scanner in = new Scanner(System.in);

      // get first input
      System.out.print("What is your name? ");
      String name = in.nextLine();

      // get second input
      System.out.print("How old are you? ");
      int age = in.nextInt();
      
      
    /* int i;
     String value="100";
     i=Integer.parseInt(value);
     i=200;
     String s=String.valueOf(i);*/
     
      // display output on console
      System.out.println("Hello, " + name + ". Next year, you'll be " + (age + 1));
  
      
   }
}

  

RandomStr.java:随机生成6位验证码

  

SwitchTest.Java:

package ceshi;
import java.awt.Graphics;
import javax.swing.*;

public class SwitchTest extends JApplet {
   int choice;   

   public void init()
   {
      String input;

      input = JOptionPane.showInputDialog( 
                 "Enter 1 to draw lines
" +
                 "Enter 2 to draw rectangles
" +
                 "Enter 3 to draw ovals
" );

      choice = Integer.parseInt( input );
   }

   public void paint( Graphics g )
   {
      for ( int i = 0; i < 10; i++ ) { 
         switch( choice ) {
            case 1:
               g.drawLine( 10, 10, 250, 10 + i * 10 );
               break;
            case 2:
               g.drawRect( 10 + i * 10, 10 + i * 10,
                           50 + i * 10, 50 + i * 10 );
               break;
            case 3:
               g.drawOval( 10 + i * 10, 10 + i * 10,
                           50 + i * 10, 50 + i * 10 );
               break;
            default:
               JOptionPane.showMessageDialog(
                  null, "Invalid value entered" );
         } // end switch
      } // end for
   } // end paint()
} 

     

二、遇到的问题

   对最后一个源代码SwitchTest.Java的运行原理不清楚

三、明日计划

  完成链表的代码

    

原文地址:https://www.cnblogs.com/wmdww/p/13765062.html