⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 debugging.java

📁 经典的货郎担问题解决办法
💻 JAVA
字号:
/*** This code was written by Kent Paul Dolan.  See accompanying file** TravellerDoc.html for status for your use.*/package com.well.www.user.xanthian.java.tools;import java.util.*;import com.coyotegulch.tools.*;public class Debugging{/*** Provide a pause facility, so that visual debugging stuff can be** studied before it is replaced.  Mostly this is a wrapper to** accomplish the required try/catch mechanism.*/  public static void snooze( long howLong )  {    {      try      {        Thread.sleep( howLong );      }      catch (Exception e) {}    }  }/*** Provide debugging aids, which stringify an array into a** pretty format to use in a debugging dump.*/    public static String dump(boolean a[])    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < a.length; i++ )      {        b.append( ( ( i == 0 ) ? "" : "," ) + ( a[i] ? "t" : "f" ) );      }      b.append("]");      return b.toString();    }    public static String dump(int a[])    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < a.length; i++ )      {        b.append( ( ( i == 0 ) ? "" : "," ) + String.valueOf( a[i] ) );      }      b.append("]");      return b.toString();    }    public static String dump(double a[])    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < a.length; i++ )      {        b.append( ( ( i == 0 ) ? "" : "," ) + String.valueOf( a[i] ) );      }      b.append("]");      return b.toString();    }    public static String dump(int a[][])    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < a.length; i++ )      {        if ( a[i] != null )        {          b.append( ( ( i == 0 ) ? "" : "," ) );          b.append("(");          for ( int j = 0; j < a[i].length; j++ )          {            b.append( ( ( j == 0 ) ? "" : "," ) + String.valueOf( a[i][j] ) );          }          b.append(")");        }      }      b.append("]");      return b.toString();    }    public static String dump(double a[][])    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < a.length; i++ )      {        b.append( ( ( i == 0 ) ? "" : "," ) );        b.append("(");        for ( int j = 0; j < a[i].length; j++ )        {          b.append( ( ( j == 0 ) ? "" : "," ) + String.valueOf( a[i][j] ) );        }        b.append(")");      }      b.append("]");      return b.toString();    }    public static String dump( Vector v )    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < v.size(); i++ )      {        if ( v.elementAt(i) == null )        {          b.append( ( ( i == 0 ) ? "" : "," ) + "(null)" );        }        else        {          b.append( ( ( i == 0 ) ? "" : "," ) + v.elementAt(i).toString() );        }      }      b.append("]");      return b.toString();    }    public static String dump( Object o[] )    {      StringBuffer b = new StringBuffer("");      b.append("[");      for ( int i = 0; i < o.length; i++ )      {        if ( o[i] == null )        {          b.append( ( ( i == 0 ) ? "" : "," ) + "(null)" );        }        else        {          b.append( ( ( i == 0 ) ? "" : "," ) + o[i].toString() );        }      }      b.append("]");      return b.toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -