【问题标题】:How can I declare types of Pascal in Java?如何在 Java 中声明 Pascal 的类型?
【发布时间】:2013-07-01 07:07:24
【问题描述】:

最近我正在根据我一年前在 Pascal 中编写的程序开发我的项目。在这个项目中,我必须将其转换为 java 并将其转换为应用程序。当我尝试声明变量时,我被卡住了。这是我的帕斯卡代码:

const choiceno=15;
  maxword=1500;
  maxlen=20;

type stringtype = string[maxlen];
     wordtype = record
              words:stringtype;
              no:integer
            end;

var  diskfile,savetxt:text;
     style,aparno,eparno,wordno,wordpt,punno,choice,code,error:integer;
     strg:string[3];
     path:string;
     sensitive:boolean;
     wordct:array[1..maxword] of wordtype;
     letterno:array[97..122] of integer;
     capletno:array[65..90] of integer;

我在 Java 中尝试过,但似乎并不令人满意:

public final int ChoiceNo = 15;
public final int MaxWord = 1500;
public final int MaxLength = 20;
public String string ;
public int record;
public String Words;
public int No;
public String DiskFile;
public String Savetxt;
public int Style;
public int AparNo;
public int EparNo;
public int WordNo;
public int Wordpt;
public int PunNo;
public int Choice;
public int Code;
public int Error;
public String strg;
public String path;
public boolean Sensitive;
String[] WordCt = new String[MaxWord];
int[] LetterNo = new int[26];

我面临的问题是我对在 Java 中声明类型没有任何想法,谁能给我一些帮助?非常感谢。

【问题讨论】:

  • 您可以查看变量保存的数据并相应地选择类型。
  • 我已经编辑并把我在Java中所做的事情,请看一下
  • 在类中定义您的自定义类型或结构,在 java 中创建一个类并在其中为自己的类型设置您想要的字段,然后在您的应用程序的任何地方像新类型一样使用它
  • 好的,我试试,非常感谢
  • 你不认为在尝试用它做点什么之前先学习至少一门语言的基础知识会很方便吗?如果你连创建变量的问题都得问,剩下的你要怎么做……

标签: android types pascal declare


【解决方案1】:

看看这些页面herehere,它解释了一些差异。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    相关资源
    最近更新 更多