当前位置: 技术问答>java相关
请问这是什么错误?
来源: 互联网 发布时间:2015-05-18
本文导语: 一段提取字符串的函数,结果出现错误,请问这是什么错? F:>javac test.java test.java:7: non-static method splitCount(java.lang.String) cannot be referenced from a static context int iCount = splitCount(sInput); ...
一段提取字符串的函数,结果出现错误,请问这是什么错?
F:>javac test.java
test.java:7: non-static method splitCount(java.lang.String) cannot be referenced from a static context
int iCount = splitCount(sInput);
^
test.java:12: non-static method splitString(java.lang.String,int,int) cannot be referenced from a static context
sArray[i]=splitString(sInput,i,iCount);
^
2 errors
我的程序源代码如下:
class test
{
public static void main(String args[])
{
String sArray[];
String sInput="12345,23456,34567,45678";
int iCount = splitCount(sInput);
sArray= new String[iCount];
for(int i=0;i
F:>javac test.java
test.java:7: non-static method splitCount(java.lang.String) cannot be referenced from a static context
int iCount = splitCount(sInput);
^
test.java:12: non-static method splitString(java.lang.String,int,int) cannot be referenced from a static context
sArray[i]=splitString(sInput,i,iCount);
^
2 errors
我的程序源代码如下:
class test
{
public static void main(String args[])
{
String sArray[];
String sInput="12345,23456,34567,45678";
int iCount = splitCount(sInput);
sArray= new String[iCount];
for(int i=0;i