小编mde*_*itt的帖子

使矩形透明

我需要使绘制的矩形鼠标透明,以便看到桌面。以下代码绘制了我的矩形。我应该添加什么来获得它?感谢帮助

public void start(Stage primaryStage) {
    Group group = new Group();

    Rectangle rect = new Rectangle(20,20,200,200);

    rect.setArcHeight(15);
    rect.setArcWidth(15);

    rect.setStroke(Color.BLACK);
    group.getChildren().add(rect);

    Scene scene = new Scene(group, 300, 200);
    primaryStage.setScene(scene);
    primaryStage.show();
}
Run Code Online (Sandbox Code Playgroud)

java stage scene javafx-8

5
推荐指数
2
解决办法
1万
查看次数

如何为对象的ArrayList创建toString方法?

我的任务是toString()为中的每个对象创建一个方法ArrayList。我不知道该怎么做。这是具有ArrayList

public class DogManager {
    private ArrayList<Dog> dogList;

    public DogManager() {
        this.dogList = new ArrayList<Dog>();
    }

    public void addDog(String nameOfDog) {
        this.dogList.add(new Dog(nameOfDog));
    }

    public String toString() {
        String results = "+";
        for (int i = 0; i < this.dogList.size(); i++) {
            results += " " + this.dogList.get(i);
        }
        return results;
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道这toString()是错误的,但是我不知道如何使它返回该列表中每个对象的描述。

java arraylist

4
推荐指数
1
解决办法
2万
查看次数


不理解double类型到byte类型的转换结果

你好我从我的书中有任务写这段代码

public class EkspKonverzija 
{
    public static void main(String args[])
    {
        byte b;
        int i=257;
        double d= 323.142;

        b=(byte) i;
        System.out.println("i and b "+i+" "+b);

        i=(int) d;
        System.out.println("d and i "+d+" "+i);

        b=(byte) d;
        System.out.println("b and d "+b+" "+d);


    }
}
Run Code Online (Sandbox Code Playgroud)

结果是:

我和b 257 1

d和i 323.142 323

d和b 323.142 67

我理解为什么第一次转换的结果是1,我也理解第二次转换,但我不知道为什么结果67在最后一次转换,我无法弄清楚所以我需要你的帮助.谢谢

java casting type-conversion

3
推荐指数
1
解决办法
161
查看次数

注释是一种AOP吗?

从Oracle:

注释是元数据的一种形式,它提供有关程序的数据,该数据不属于程序本身。注释对其注释的代码的操作没有直接影响。

和来自维基百科:

在计算中,面向方面的编程(AOP)是一种编程范例,旨在通过允许跨领域关注点的分离来提高模块化。AOP为面向方面的软件开发奠定了基础。

我的问题是:如果我使用@EJB,则可以说我正在使用AOP吗?因为@EJB对我来说,这似乎是一个横切关注的问题(例如,查找资源)。请说明是或否,或者有时注释是AOP。

java aop

3
推荐指数
1
解决办法
417
查看次数

zeller的同余代码出错

public static void main(String [] args)
{
    Scanner input = new Scanner(System.in);
    System.out.print("Enter the month (1-12):");
    int month = input.nextInt();
    System.out.print("Enter the day (1-31):");
    int day = input.nextInt();
    System.out.print("Enter the year (ex. 2014):");
    int year = input.nextInt();

    if (month == 1)
        month = 13;
    else if (month == 2)
        month = 14;

    int Zeller = day + ((26 * (month + 1)) / 10) + year +
        (year / 4) + (6 * (year / 100)) + (year / 400); …
Run Code Online (Sandbox Code Playgroud)

java

2
推荐指数
1
解决办法
480
查看次数

格式化toString Java

我想知道如何格式化toString:我尝试使用printf和s tring.format,但要我改变String,并int以Object[]

我希望它看起来像这样:(空格)

Book1______Author1________850

Book23_____Author2424_____250

class Book
{
    private String title,author;
    private int numberOfPages;

    Book()
    {

    }

    public Book(String title, String author, int pages) {
        this.title = title;
        this.author = author;
        this.numberOfPages = pages;
    }

    public String toString()   
    {
        return(title + "%63s") + "\t" + (author + "%63s") + "\t" + numberOfPages;
        // It actually works but makes the "%63s" appear :o
    }
}
Run Code Online (Sandbox Code Playgroud)

java format tostring

2
推荐指数
1
解决办法
3万
查看次数

在java中解析浮点值

当我这样做的时候

value = Float.parseFloat("5555998.558f");

System.out.println("Value: " + value);
Run Code Online (Sandbox Code Playgroud)

它给了我结果,5555998.5而不是5555998.558 我使用变量值进行某些计算.我需要确切的价值,即5555998.558

怎么克服这个?

java floating-point-conversion

2
推荐指数
2
解决办法
225
查看次数

语法错误,插入“EnumBody”完成BlockStatement

public class SumLineTester {
/**
 * @param args
 */
public static void main(String[] args) {
       // TODO Auto-generated method stub
       SumLine test = new SumLine("5 8 3 2 1");
       System.out.println(test.getSum());
    }
}


import java.util.Scanner;

public class SumLine {
    private String line;

    public SumLine(String s) {
        line = s;
    }

    public int getSum(){
        int sum = 0;
        Scanner chop = new Scanner(line);

        while(chop.hasNextInt()){
            sum= sum + chop.nextInt();
        }
        return sum;

    public String getLine(){
        return s;
    }

    public String toString(){
        return line; …
Run Code Online (Sandbox Code Playgroud)

java

1
推荐指数
1
解决办法
2万
查看次数

如何修复以下错误:"错误:在类中找不到主要方法"

我基本上是Java新手,为了好玩,我正在创建一个股市模拟器/游戏.我知道我的代码并不"完美",但请记住我是新手,我有1个错误.

"错误:在StockPackage.Dog类中找不到主要方法,请将main方法定义为:public static void main(String [] args)"

我查看了所有可以找到的参数和参数教程,并搜索了StackOverflow的问题,但找不到解决方案.

如果可以的话,有人可以想出一个"删除/修复"错误的方法,或者尽可能地帮助我.提前致谢!

我的代码:

package StockPackage;

import java.util.Scanner;    

public class Dog {      

    public static void main(String[] args, int CurMoney, String[] inputStocks, 
        int[] StockMoney) {
        Dog Run = new Dog();
        Run.MainScript();
        Run.OptionStartingMethod(inputStocks, CurMoney, StockMoney);
    }     

//==============================================================================
//                          ||Objects||
    void options(String[] inputStocks, int CurMoney, int[] StockMoney) {
        String optionEXIT, optionStartStock, optionBuyStock, optionSellStock;
        String optionCheat, optionInfo, optionCredits, optionClose, OptionInput;
        int i, j, k;            

        Scanner optionInput = new Scanner(System.in);

        Dog FlixSibling = new Dog();            

        System.out.println("=============| Options | ============="); …
Run Code Online (Sandbox Code Playgroud)

java parameters arguments

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

角度ng-class如果这个和那个,if-else表达式

如何编码?

If >= 5 myClass1
else if
< 5 myClass2
else if
< 5 and <=2 myClass3
Run Code Online (Sandbox Code Playgroud)

这部分工作正常:$ index> = 5?'hidden-md col-lg-1':

需要解决这个问题:(($ index <= 2?'col-md-4 col-lg-2'):'col-md-2 col-lg-2')

ng-class="$index >= 5 ? 'hidden-md col-lg-1' : (($index <= 2 ? 'col-md-4 col-lg-2') : 'col-md-2 col-lg-2')"
Run Code Online (Sandbox Code Playgroud)

angularjs

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

ArrayList列出null而不是对象的实例

public class Library{
    private ArrayList<Book> books = new ArrayList<Book>();

    public void addBook()
    {
        Scanner sc = new Scanner(System.in);

        System.out.println("Enter title of the book: ");
        String title = sc.nextLine();
        System.out.println("Enter the author: ");
        String author = sc.nextLine();

        String bookID = bookID();

        Book b = new Book(author,title,bookID,true);
        books.add(b);

        System.out.println( title + " by "+ author +" added to library.");
        System.out.println("Book ID: " + bookID);

    }

    public void listBooks()
    {
        for (Book temp : books)
        {
            if (temp.loanStatus() == true) System.out.print("*");

            System.out.println(temp.getTitle() + …
Run Code Online (Sandbox Code Playgroud)

java

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

错误:futureInvestmentValue无法解析为变量

我必须用Java创建一个程序,该程序使用一种方法来计算未来的投资价值,用户可以投入投资金额和利率.它必须在一张桌子上显示并有多年1-30.

我有一个错误,我无法弄清楚如何解决.错误在我所拥有//Title的main地方futureInvestmentValue.错误告诉我

futureInvestmentValue无法解析为变量

这是我的代码:

import java.util.Scanner;
public class futureInvestmentValue {    
    public static double futureInvestmentValue(double investmentAmount, 
        double monthlyInterestRate, int years){
        double futureInvestmentValue = 1;

        for (years = 1; years <= 30; years++) {
            monthlyInterestRate = years/1200;
            futureInvestmentValue = 
                investmentAmount * Math.pow((1+monthlyInterestRate), years*12);
        }
        return futureInvestmentValue;
    }           

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        //Get investment amount and yearly interest rate from user
        Scanner input = new Scanner (System.in);
        System.out.print("Enter …
Run Code Online (Sandbox Code Playgroud)

java

-3
推荐指数
1
解决办法
82
查看次数