Java programming problems

1、使用循环把26个字母按字典顺序存入数组,在不使用另外数组的情况下将其逆序存放,在根据处理后的字符数组创建一个字符串并输出

  public static void main(String[] args) {
        char a[]=new char[26],c;   //中间变量c
        int i;
        for(i=0;i<a.length-1;i++){
            a[i]=(char)(‘a‘+i);            
        }
        for(i=0;i<13;i++){
            c=a[i];
            a[i]=a[25-i];
            a[25-i]=c;    
        }
        String s=new String(a);
        System.out.println(s);
    }
}

2、设计一个动物接口,并设计相应的动作,如跑,跳,走。在设计一个狗类实现这个动物接口,该狗类具有一些基本属性,如名称,大小,体重等。编写测试类测试是

否达到预定功能。要求使用自定义的包。

3、定义两个文本框,一个文本框用于提示输入密码,另一个是密码框,以“*”代替输入的密码

  public class test2 extends Applet{    
          TextField  text1,text2;
          public void init(){
              text1=new TextField("请输入密码:",10);
              text1.setEditable(false);
              text2=new TextField(10);
              text2.setEchoChar(‘*‘);
                add(text1);
               add(text2);            
      }
  }

4、设置列表选择模型为单选:list.setSelectionMode( ListSelectionModel.SINGLE_SELECTION)

  设置列表选择模型为多选:list.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)

5、编写一个java  applet应用小程序,画三个圆,颜色分别为红黄绿

  public class test3  extends Applet {
       public void paint(Graphics g){
        g.setColor(Color.red);
        g.drawRoundRect(100, 100, 100, 100, 100, 100);
        g.drawString("红色圆", 100, 100);
        
        g.setColor(Color.green);
        //g.drawRoundRect(x, y, width, height, arcWidth, arcHeight);
        //x,y表示坐标,对于画圆后面四个参数必须相等
        g.drawRoundRect(50, 50, 50, 50, 50, 50);
        g.fillRoundRect(40, 50, 50, 50, 50, 50);//画圆填充色
        g.drawString("绿色圆", 50, 50);
    }
}

时间: 2024-10-17 22:42:21

Java programming problems的相关文章

Master the 10 Most Common Python Programming Problems - 10大最常见的Python编程错误

http://blog.csdn.net/pipisorry/article/details/45175457 Introduction 本文介绍python编程中很难捕捉10大错误 (Note: This article is intended for a more advanced audience than Common Mistakes of Python Programmers, which is geared(适合) more toward those who are newer t

Get your Advanced Java Programming Degree with these Tutorials and Courses

Getting started as a Java developer these days is quite straightforward. There are countless books on the subject, and of course an abundance of online material to study. 最近,入门成为一名java开发人员是非常简单的.有无相关的书籍,当然还有大量的在线资料可供学习 Of course, our own site offers

Java Programming Tutorial Java Native Interface (JNI)

1.  Introduction At times, it is necessary to use native codes (C/C++) to overcome the memory management and performance constraints in Java. Java supports native codes via the Java Native Interface (JNI). JNI is difficult, as it involves two languag

[LintCode] BackPack Dynamic Programming Problems

This blog talks about using dynamic programming to solve the famous back pack and its variant problems. BackPack I Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack? Notice You can not divide

C Programming vs. Java Programming

Thing C Java type of language function oriented object oriented basic programming unit function class = ADT portability of source code possible with discipline yes portability of compiled code no, recompile for each architecture yes, bytecode is "wri

WebSocket Java Programming入门-1(annotated)

1.前言 一直没有怎么做过前端的东西,但是最近的项目中,前端人员奇缺,公司又不安排新的人员进入,所以我这个后台开发人员只能拉过来坐前端了,前段的东西感觉一大堆,CSS,js自不必说,HTML生态圈就有很多的技术要去学习,好吧,那就一个一个的学习整理啦,先来说说最近这个项目的前端用到什么技术吧. 1.Restful:DropWizard这个很简单,两天基本上就能拿下 2.Js Framework :AngularJS 这个JS库的确很酷,最近学习的过程中越来越喜欢这个东西了,打算以后再整理一些An

[JAVA Programming] 关于JList的一点笔记

这次写JAVA课的大作业,首先不得不佩服所给的dictionary.txt文件的厉害之处啊,各种大小写.连字符还有各种词组的不同情况在自己测试的时候都中奖了,我该高兴么... 其实要求不高,大概就是一个词典的查询软件,提供了后台词典,只要完成其中的文件I/O,进行String的处理就可以了. 下面其实主要是一些算法问题,查找的话,既然有序(但是从某些角度说,'-'的值要比a-z小啊,但是在dictionary中的顺序却不是这样啊~~所以我暴力地进行了一次QuickSort...)果断O(logn

Chapter 2 The Java Programming Environment

1. Installing the Java Development kit (JDK) 2. Choosing a Develpment Environment 3. Using the Command-Line Tools 4. Using an Integrated Development Environment 5. Running a Graphical Application 6. Building and Running Applets In this chapter, we wi

Java Programming Test Question 3

import java.util.HashSet; public class JPTQuestion3 { public static void main(String[] args) { HashSet shortSet = new HashSet(); for (short i = 0; i < 100; i++) { shortSet.add(i); shortSet.remove(i - 1); } System.out.println(shortSet.size()); } } 输出: