小编mra*_*ahh的帖子

如何在Java中查看内置类的源代码(例如BigInteger等)?

例如,在某些编译错误期间,我可以访问发生错误的一些内置源代码(可能是main中的周长错误).如何手动访问这些相同的源代码?我主要对BigInteger类感兴趣.

java

6
推荐指数
1
解决办法
3171
查看次数

将整个代码块转换为C中的一行

比方说,我想将整个代码块输入一个命令:

int k = 0;

for (k = 0; k < 50; k++) 
{
    sprintf(buf, "M LR 10 -10\n");                     //We put the string "M L 10" into the string buffer.
    write(sock, buf, strlen(buf));                     //We send the buffer into the socket.
    memset(buf, 0, 80);                                //Clear the buffer, set buffer to value 0.
    read(sock, buf, 80);                               //Read from the socket to get the results.
    int lme, rme;
    sprintf(buf, "S MELR\n");                          //sensor command to find ME values
    write(sock, buf, strlen(buf));                     //sends the buffer …
Run Code Online (Sandbox Code Playgroud)

c

0
推荐指数
1
解决办法
117
查看次数

尝试反转数组时ArrayIndexOutOfBoundsException

这看起来很简单,但我得到了错误 "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at reverse.main(reverse.java:28)"

我最初从用户那里获取输入来编写数组,然后我想向后打印数组.我知道还有其他方法可以做到这一点,但我主要想知道为什么这不起作用.逐行完成它是有道理的吗?

PS.如果这不是问题,有没有更好的方法呢?

import java.util.Scanner;


public class reverse {

    /**
     * @param args
     */
    public static void main(String[] args) {
        System.out.printf("Enter the number of values in array: ");
        Scanner scanner = new Scanner(System.in);
        int n;
        n = scanner.nextInt();

        double[] a1 = new double[n];
        int i;

        System.out.printf("Enter the value in the array: ");
        for (i = 0; i < n; i++){
            Scanner scanner2 = new Scanner(System.in);
            a1[i] = scanner2.nextInt();
            }
         double j;
         double …
Run Code Online (Sandbox Code Playgroud)

java arrays

0
推荐指数
1
解决办法
146
查看次数

标签 统计

java ×2

arrays ×1

c ×1