小编cod*_*ict的帖子

Java静态方法无法编译

编译此代码时出现以下消息.

Question2中的ExtractChars(java.lang.String,int)无法应用于()

我该怎么办?

谢谢.

import java.util.Scanner;

public class Question2
{

    public static void main (String[] args)
    {

        ExtractChars();

    }
    public static String ExtractChars(String sOrg, int startPos)
    {

        Scanner scan = new Scanner (System.in);
        String value = "";
        System.out.print("Enter a string: ");
        sOrg = scan.next();
        System.out.print("/nEnter an integer: ");
        startPos = scan.nextInt();
        if (sOrg.length()<=startPos)
        {

            value = "";

        }
        else
        {
            for (int i=startPos; i<sOrg.length();i=i+2)
            {

                value = value + sOrg.charAt(i);

            }
        }

        return value;
    }
}
Run Code Online (Sandbox Code Playgroud)

java methods static compiler-errors function

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

修改现有的正则表达式以匹配'.' 藏汉

我目前正在使用这个正则表达式^[A-Z0-9 _]*$来接受字母,数字,空格和下划线.我需要修改它以允许.

regex

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

这在$ variable-> function()中是什么意思( - >)?

大家好我已经看了很多PHP脚本,我看到了这样的东西

$variable->function($var1, $var2, $var3)
Run Code Online (Sandbox Code Playgroud)

那究竟->是做什么的呢?

谢谢你

php oop

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

我可以用C开始编程吗?

我想开始编程我没有以前的编程经验所以可以用C开始编程吗?有些人告诉我从perl或python开始..所以我可以开始学习它而不先学习python或perl吗?..如果那么史蒂夫·科坎的"编程在c"一书中的表现是否良好?... http://goo.gl/Jh6bE

c

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

两个数字的LCM

我的LCM计划结果出错了.

如果找到数字的gcd,然后用gcd划分产品.

int gcd(int x, int y)
{
  while(y != 0)
  {
    int save = y;
    y = x % y;
    x = save;
  }
  return y;
}

int lcm(int x, int y)
{
  int prod = x * y;
  int Gcd = gcd(x,y);
  int lcm = prod / Gcd;

  return lcm;
}
Run Code Online (Sandbox Code Playgroud)

任何帮助非常感谢.

c algorithm overflow lcm greatest-common-divisor

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

在函数返回中将数组转换为指针

我在C++中遇到了关于指针的问题.代码是:

int * initArray() {
    int a [2];

    a[0] = 1;
    a[1] = 2;
    return a;
}


int main () {
    int * b = initArray();

    cout << b << "---" << *(b) << endl;
    cout << b + 1<< "---" << *(b + 1) << endl;
}
Run Code Online (Sandbox Code Playgroud)

输出是

0021FC20---1
0021FC24---1431629120
Run Code Online (Sandbox Code Playgroud)

你可以看到值是错误的.

当我尝试将init数组代码放入main函数时,它正确运行.

你能告诉我的代码有什么问题吗?

c++ pointers return function

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

fork()之后,child没有执行

int status=0;
int PID = fork();
if(PID == 0)
{
   char *path = strcat(pathToken,strcat("/",command));
   printf("path: %s\n",path);
   execl(path,command,"-l",NULL);
}
else if(PID>0)
{
   printf("pid: %d. ",PID);
   printf("I'm parent process\n");
   wait(&status);
}
Run Code Online (Sandbox Code Playgroud)

输出:

pid: 20027. I'm parent process
Run Code Online (Sandbox Code Playgroud)

为什么不进入if(PID==0)

c linux fork runtime-error exec

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

onDraw经常打电话

我有一个显示地图的方法.我在onDraw方法中调用此方法.但在动作移动我需要重绘地图,需要再次调用该方法,但我没有得到画布参考重绘地图图块.我使用了invalidate方法,但它经常刷新onDraw,这使得我的地图运动也变慢了..

这是我的onDraw方法.

protected void onDraw(Canvas canvas)
        {   
            Log.i("On Draw Call", "On Draw call");
            mapMaker.getMapForScreenArea(map.getiScrnArea(), mapType, input, canvas);

            invalidate();
            this.canvas = canvas;
        }
Run Code Online (Sandbox Code Playgroud)

任何帮助都将是值得的.非常感谢.

android

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

为什么这段代码产生"语法错误,意外'='"?

$text . = '1 paragraph';
$text . = '2 paragraph';
$text . = '3 paragraph';
echo $text;
Run Code Online (Sandbox Code Playgroud)

此代码给出错误syntax error, unexpected '='.

问题是什么?

php string concatenation syntax-error echo

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

如何在C++中返回数组?

为什么以下代码不起作用?

它编译得很好但输出就像地址,如果我写f使用*,输出是0如果我写f没有*.

#include <iostream>
#include<cstring>
using namespace std;
using std::size_t;
int *f(size_t s){
    int *ret=new int[s];
     for (size_t a=0;a<s;a++)
          ret[a]=a;
      return ret;
      }
int main(){

    size_t s=20;
    cout<<*f(s)<<endl;

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

c++ arrays return

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

为什么Perl会在使用此HTML字符串编译程序时抱怨语法错误?

我的代码中遇到了问题.每当我尝试插入文本字段时,它就会出错.这里的语法有什么问题?

   print '<table>';
  print "<tr style='background-color:#CDC9C9;'>
<td><A HREF=\"http://localhost/cgi-bin/AddUser.cgi\">ADD</A></td>
<td></td>
<td><b>UserId</b></td>
<td><input type="text" name="UserId"></td>
<td><b>UserName</b></td>
 <td><input type="text" name="User_Name"></td>
 <td><input type="submit" name="Filter" value="Filter">  </td>
  </tr>";
print"</table>"; 
Run Code Online (Sandbox Code Playgroud)

html string perl

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

我的代码有什么不对?

#include <iostream> 

using namespace std;

float sum(float a,float b);

float subs(float a, float b);

float multiple(float a, float b);

float division(float a, float b);

int main()

{//main

    int a,b;

    char o ;
    cout<<"input your calculation with  operation (+,-,/,*) such as 5+6 : /n ";
    cin >> a >> o >> b ;
    switch('o')
    {
    case '+':

        sum(float a, float b);
        break;

    case '-':

        subs(float a, float b);
        break;

    case '*':

         multiple(float a, float b);
        break;

    case '/':

         division(float a, float …
Run Code Online (Sandbox Code Playgroud)

c++

-5
推荐指数
1
解决办法
129
查看次数