小编all*_*ded的帖子

Java构造函数使用多种方法重载

我在课堂上有一个程序任务.我已经理解了重载的基础知识,但我对一点非常困惑.如何仅从我尝试使用的方法输出?那么让我告诉你代码而不是解释.

public class Box {
 private int length, width, height;

 public Box(int length){
  this.length=length;
  System.out.println("Line created with length of" + length + ".");
 }
 public Box(int length, int width){
  this.length = length;
  this.width = width;
  System.out.println("Rectangle created with the length of " + length + " ");
  System.out.println("and the width of " + width + ".");
 }
 public Box(int length, int width, int height){
  this.length=length;
  this.width=width;
  this.height=height;
  System.out.println("Box created with the length of " + length + ", ");
  System.out.println("the …
Run Code Online (Sandbox Code Playgroud)

java constructor-overloading

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

被告知我的代码不是递归...寻找指导为什么不!

有人向我指出,下面的陈述不是递归.我认为递归只意味着它会调用自己直到找到答案.什么会导致这种递归?

public static double totalDistance(int[] x, int[] y, String[] city, int i){

    double xSub = x[i] - x[i-1];
    double ySub = y[i] - y[i-1];
    double distance = Math.pow(xSub, 2) + Math.pow(ySub, 2);
    distance = Math.round(Math.sqrt(distance));
    System.out.println("Distance From " + city[i] + " to " + city[i-1] + " is " + distance + " miles.");

   if (i == 1){
       return distance;  
   }
   else {
      return distance+totalDistance(x,y,city, i-1);
   }
}
Run Code Online (Sandbox Code Playgroud)

这是以下整个代码,以防任何人对正在发生的事情感到好奇......

import java.util.Scanner;
class distance {


public static void main(String[] args) …
Run Code Online (Sandbox Code Playgroud)

java recursion

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

使用Javascript解析格式错误的JSON

我想用Javascript 解析这个内容.数据如下所示:

{"ss":[["Thu","7:00","Final",,"BAL","19","ATL","20",,,"56808",,"PRE4","2015"],["Thu","7:00","Final",,"NO","10","GB","38",,,"56809",,"PRE4","2015"]]}

在线的每一个教程都教你如何使用Twitter解析JSON,但我不太确定如何使用JSON进行解析.

我想在一个网站上设置这个以查看NFL团队得分,以获得一个有趣的项目和一个关于解析JSON的良好学习经验,因为我不太关心Twitter的东西.

这可能吗?任何好的教程开始?甚至一些启动代码?

javascript parsing json

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

指数超出范围.必须是非负误差

我不断得到一个超出范围异常的索引.不得为非负数且小于集合的大小.

问题是当我检查toRemove计数低于受访者时.那么这个错误是怎么发生的?如果5个在respondentstoRemove只有3个那么这个错误是怎么发生的?

var respondents = RespondentRepository.GetRespondents(UserSession, fieldsToInclude);

// iterate through the respondents. If search query not like results throw the result away.
List<int> toRemove = new List<int>();
for (int i = 0; i < respondents.Count; i++)
{
    if (!respondents[i].EmailAddresses.Any())
        toRemove.Add(i);
    else
    {
        bool checkSingleEmail = false;
        bool checkAllEmails = false;
        for (int j = 0; j < respondents[i].EmailAddresses.Count; j++)
        {
            checkSingleEmail = respondents[i].EmailAddresses[j].Address.ToString().Contains(query);

            if (checkSingleEmail == true)
                checkAllEmails = true;

            if (respondents[i].EmailAddresses.Count == 1 …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

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

Java密码程序循环永远需要帮助

为什么即使我输入超过6个字符的长度,也只是永远重复?

import java.util.Scanner;

class Password {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

        System.out.println("Welcome please enter your username and password.");
        System.out.print("Username >>");
        input.nextLine();
        enterPassword();
        System.out.println("Successfully Logged In");
        }

    public static void enterPassword(){
        String password;
        Scanner input = new Scanner(System.in);
        System.out.print("Password >>");
        password = input.nextLine();
        checkPasswordLength(password);
        }


    public static void checkPasswordLength(String password){
        int length;
        length = password.length();
        while (length <6){
            enterPassword();
            }
        checkPasswordLetter(password);
        }

    public static void checkPasswordLetter(String password){
        System.out.println("More checking here to be added");
        }
}
Run Code Online (Sandbox Code Playgroud)

java

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

Java代码检查字母和数字的密码?

编辑 - 版本第一篇文章是confusamagin.我的任务是创建一个密码提示程序.需要检查密码以查看其中是否至少有一个数字和一个字母.密码长度也必须在6到10之间.

我的问题是试图弄清楚如何查看数字和字母是否存在密码.在检查密码区域,我不知道从哪里开始.我不知道怎么看它是否有一个字母和一个数字.我知道如何做或者使用for语句进行计数和检查,但它所做的只是检查它是否包含所有字母或所有数字.

以下是我到目前为止的情况......

import java.util.Scanner;

class Password {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);

//------ENTER A USERNAME
        System.out.println("Welcome please enter your username and password.");
        System.out.print("Username >>");
        input.nextLine();


//------PASSWORD AUTHENTICATION BEGIN       
        String password = enterPassword();
            while ( !checkPassword(password) ) {
            System.out.println("Password must be 6 - 10 characters long!"); 
            password = enterPassword();
            }

//------PASSWORD VERIFY
        String passwordverify = enterPassword();
        while (!password.equals(passwordverify)){
            System.out.println("ERROR - Passwords DO NOT MATCH Re-Enter Passwords Again");
            password = enterPassword();

        }

//------ACCEPT …
Run Code Online (Sandbox Code Playgroud)

java authentication passwords

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

PHP将数组循环到多维数组中?

我有一个带有8个值的直接数组.我想把它变成一个多维数组.目前它看起来像这样:

array(8) {
  [0]=>
  int(0)
  [1]=>
  float(100)
  [2]=>
  int(0)
  [3]=>
  int(0)
  [4]=>
  float(0.5)
  [5]=>
  float(53.6)
  [6]=>
  float(32.8)
  [7]=>
  float(9.4)
}
Run Code Online (Sandbox Code Playgroud)

使用上面的值我希望数组格式如下:

array[0][0] = 0
array[0][1] = 100

array[1][0] = 0
array[1][1] = 0

array[2][0] = .5
array[2][1] = 53.6
Run Code Online (Sandbox Code Playgroud)

等等

因此,目标是创建一个循环,并将每2个值设置为数组中的数组.有任何想法吗?

php arrays loops multidimensional-array

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

访问SQL Azure数据库时无法在SSMS 2012中输入设计视图

访问Windows azure数据库时,如何在表上的SQL Server Management Studio 2012中输入设计视图?

SSMS

sql-server ssms azure

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

Azure推送通知REST没有在指定的地址托管任何服务

我正在使用Azure移动服务来执行推送通知。我创建了一个推送通知服务总线。当我尝试通过REST服务连接到该服务器时,得到以下响应:

404No service is hosted at the specified address. TrackingId:dfc9aea1-e229-4eb7-b393-c8cd6bce258d_G19,TimeStamp:11/3/2014 8:39:21 PM
Run Code Online (Sandbox Code Playgroud)

POSTMAN请求看起来像这样,它重复了这个问题: 在此处输入图片说明

由于该服务在那里,如何进一步解决此问题?我想念什么?

rest azure push-notification azure-mobile-services

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

SQL选择转换为Linq的位置

我试图从使用Linq的数据库中选择.我试图重现的查询是:

   "Select * From Avatars Where userId IN (1, 2, 3)"
Run Code Online (Sandbox Code Playgroud)

如果我有一个userIds列表,如何用lambda编写.

我卡在哪里!! 是和有一个userIds列表:

context.avatars.Where(a => a.userId == !!(userIds)!! )
Run Code Online (Sandbox Code Playgroud)

c# linq lambda

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