26 questions to answer written algorithm


Note: Some slight changes


To an integer into an array after reverse (required recursion)

package org.stack_queue;
public class Algorithm {

        //  Will a integer reverse in an array  ( Requires recursive implementation  )
        public void reverse(StringBuffer result, int num) {
                if (num != 0) {
                        result.append(num % 10);
                        reverse(result, num / 10);

        public static void main(String[] args) {
                StringBuffer result = new StringBuffer();
                new Algorithm().reverse(result, 1024);



] Recursive palindrome judgments (such as: abcdedbca is palindromic, the interviewer to judge a simple understanding of the recursive procedure)

package org.stack_queue;
public class Algorithm {

         *  Recursive implementation Palindrome judgment  ( If  :abcdedbca It is a Palindrome, interviewer on recursive understand the simple program  )
         * @param str
         *             To determine whether the string
         * @param begin
         *            0
         * @param end
         *             The length of a string
         * @return
        public static boolean isPalindrome(char[] str, int begin, int end) {
                if (end <= 1)
                        return true;
                if (str[begin] == str[end]) {
                        return isPalindrome(str, begin + 1, end - 1);
                } else
                        return false;

        public static void main(String[] args) {
                char[] str = new String("abcdedbca").toCharArray();
                System.out.println(Algorithm.isPalindrome(str, 0, str.length - 1));
                char[] str2 = new String("acbca").toCharArray();
                System.out.println(Algorithm.isPalindrome(str2, 0, str2.length - 1));
分类:Java 时间:2010-06-20 人气:172
blog comments powered by Disqus


  • public static void main (String args []) parameters 2010-05-15

    String args [] is the main function of main parameters, namely array of strings. Using eclipse in the editing, right-click to run the Java files in the Run As option, select Run Configurations. Main class in the Project and complete the project, resp

  • Why public static void main (String args []){} 2010-11-06

    main () is a Java program entry, program execution is the beginning of this entry. Class is a class member, main () method must be public members. So that it can be called in the execution environment. main () method does not produce the object can b

  • 浅析C#中的Main(String[] args)参数输入问题 2014-07-20

    本篇文章主要是对C#中的Main(String[] args)参数输入问题进行了详细的介绍,需要的朋友可以过来参考下,希望对大家有所帮助 指定相关的测试代码 首先,写一个用于测试的关于Main(String[] args)参数输入有关的代码类,如下: using System; public class Hello { public static void Main(String[] args) { switch (args[0]) { case "老板": Console.Write

  • How the eclipse of the main the String [] args parameter passed, and then export it 2010-12-26

    How the eclipse of the main the String [] args parameter passed, and then export it? In the Run menu to find Open Run dialog opens Select Java Application in the program need to run Select the Arguments Tab Enter the parameters in the Programe Argume

  • Java String object, the classic problem of (new String ()) [switch] 2011-08-05

    Look at an example, the code is as follows: Java code public class Test { public static void main (String [] args) { String str = "abc"; String str1 = "abc"; String str2 = new String ("abc"); System.out.println (str == str1);

  • public void testStatementAddBatch () public void testConnCommit () 2011-09-01

    public void testStatementAddBatch() { Connection conn = null; Statement stmt = null; try { conn = getDBConnectionMsSqlBySuperAdmin(); stmt = conn.createStatement(); for(int i = 0; i < 100; i++) { String sql = " sql " + i; stmt.addBatch(sql);

  • Javs get all the methods of the reflection 2010-04-17

    package com.cn.service; public interface China { public static final String NATIONAL="China"; public static final String AUTHOR=" Lao Li "; public void sayChina(); public String sayHello(String name,int age); } package com.cn.model; im

  • java call ffmpeg to convert video formats to flv 2010-04-27

    these days to write a video management system, have a very big problem is if the different format to flv, format,! After some online searching, his summing up, finish, finishing, and finally the whole out! Realized the video conversion is also capabl

  • Difference between overloading and override 2010-09-16

    Difference between heavy and sometimes covering the class of the same function has a variety of ways, in the end achieved by that method, the caller depends on the given parameters. For example, teachers can train animals, acrobatics, for different a

  • Understanding of Java reflection 2010-11-14

    Understanding of Java reflection Under normal circumstances, you must know before they can instantiate a class object, but also by a Java object to find its information in the class, this is actually a function of the class Class. package zyz.demo; c

iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.053 (s). 13 q(s)