小编Shi*_*rty的帖子

分割成多行

我有一条线.对于这条线,我有起点和终点.现在我想将这条线分成多行或多个点.怎么做?

这条线看起来像下面..

在此输入图像描述

任何的想法?

geometry line

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

int to Long解析错误

  class Test{  
    static void testCase_1(long l){System.out.println("Long");}  
    static void testCase_2(Long l){System.out.println("Long");}

    public static void main(String args[]){  
        int a = 30; 

        testCase_1(a);  // Working fine
        testCase_2(a);  // Compilation time error

        //Exception - The method testCase_2(Long) in the type Test is not applicable for the arguments (int)
      }   
    } 
Run Code Online (Sandbox Code Playgroud)

testCase - 1:int - 长期正常工作

testCase - 2:int to L ong抛出异常

为什么testCase_2()方法抛出编译异常?

java

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

三个图像失真

我正在使用threejs绘制3D形状.我使用MeshLambertMaterial绘制此形状但图像显示不正确.

如何解决这个问题?在此输入图像描述

three.js

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

为什么 没有显示任何例外?

当我使用eclipse ID时,我突然发现我在变量声明中加了双分号.

以下是我的发言

double defaultValue = 0.0;;
Run Code Online (Sandbox Code Playgroud)

我在这里感到困惑.我期望上面的语句抛出一个异常,但我错误的上面的语句运行没有任何错误.

为什么双分号没有显示任何错误?

java

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

split不能在java中工作的字符串无法导入`split`

我试图拆分字符串作为下面的代码

String []data = {"3.5,2.3,4.2,5.4,7.4,2.7"};
String s[] = data.split("\\,");

double point3[] = new Double [s.length];
double allPoint[] = new double [s.length];

for (int i = 0; i < s.length; i++){
   point3[2] = Double.parseDouble(s[2]);
   //lng[i] = Double.parseDouble(s[i]);
   allPoint[i] = Double.parseDouble(s[i]);
}
Run Code Online (Sandbox Code Playgroud)

我也试过data.split(","); 问题不是反斜杠,它给出错误,split提示显示

找不到符号,符号:方法split(String)

我无法导入split 我现在可以做的事情.

java string split

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

Sonar lint:不应检查“compareTo”结果的特定值

我正在比较两个值并得到声纳棉绒投掷"Only the sign of the result should be examined" this issue

代码 :

if (recBalanceAmt.compareTo(recRolloverEligibility) == 1) {
     recExpAmt = recBalanceAmt.subtract(recRolloverEligibility);
}
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?

java sonarqube sonarlint

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

降低代码的复杂性

我使用下面的代码,并根据逻辑使用了两个continue语句,但声纳列表显示了此问题 Reduce the total number of break and continue statements in this loop to use at most one.

如何解决这个问题?

for (HashMap<String, String> objRequestIdVO : pObjTicketId) {
    List<TicketDetailsDO> objTicketDetailslist = storeManagerDao.getTicketDetailsWithTicketId(objRequestIdVO.get("requestId"));
    if (null == objTicketDetailslist || objTicketDetailslist.isEmpty()) {
        continue;
    }

    Integer iDesiredDsicount = objTicketDetailslist.get(0).getDesiredDiscount();
    String iSubDept = objTicketDetailslist.get(0).getSubdeptTicket().getSubDeptId();
    List<MCouponDO> objMCounponList = storeManagerDao.getMcouponData(iDesiredDsicount, iSubDept);

    if (null == objMCounponList || objMCounponList.isEmpty()) {
        continue;
    }

    String strHeader = objMCounponList.get(0).getHeader();
    objHeaderVO = new HeaderVO();
    objHeaderVO.setHeader(strHeader);
    objHeaderVO.setRequestId(objRequestIdVO.get("requestId"));
    objHeaderVOList.add(objHeaderVO);
}
Run Code Online (Sandbox Code Playgroud)

java sonarlint

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

而重写方法则面临问题

当覆盖方法然后面临一个问题:

public interface IProduct {
    public void sendMessage(Object object);
}


@Service
public class ProductManagere implements IProduct{

    @Override
    public void sendMessage(Product product) {
        // Added logic
    }
}
Run Code Online (Sandbox Code Playgroud)

但要低于例外:

ProductManagere类型的sendMessage(Product)方法必须覆盖或实现超类型方法

我不明白为什么抛出这个例外.我希望product是Object的子类型,所以它不会抛出异常.

java generics methods interface

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

存在Java 8 lambda表达式

首先,我需要检查列表中是否存在数据,然后在Java 8流上获取其他设置的默认值或空值.

目前我使用下面的代码,isPresent但我不知道如何在java8中使用isPresent.

我正在尝试下面不完美的东西:

String isScheme = (this.mapProgramApproaches.stream().findFirst().isPresent())? this.mapProgramApproaches.stream().findFirst().get().getIsScheme().toString() : "0";
Run Code Online (Sandbox Code Playgroud)

凡为mapProgramApproaches这个设置.

java lambda

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

比较带有原始int的Integer对象

我正在将整数对象与原始int进行比较,但是如果Integer对象是,则会得到空指针异常 null

public static void main(String[] args) {

        Integer a = null;
        int b = 1;

        if (a != b) {
            System.out.println("True");
        }

    }


Output : Exception in thread "main" java.lang.NullPointerException
    at com.nfdil.loyalty.common.Test.main(Test.java:10)
Run Code Online (Sandbox Code Playgroud)

我得到这个是因为它试图转换null integer object (a.intValue()) into primitive int

还有其他方法可以避免这种情况吗?

java

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