我有8 JLabels,我最初想隐形.在jlabels从25日开始,进入32 _(i.e jLabel25 ---> jLabel32)_个我想用一个for循环,可以使他们看不见按照这几行代码,而不是把无形之一:
for( int i = 25 ; i <= 32 ; i++ ) {
jLabel(i).setVisible(false);
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个明显的错误,上面写着"找不到符号,方法 - > jLabel(int)"
我该怎么做才能避免写出8个声明,要求让每个label看不见?
我有一个String存储路径.当我打印路径时,它就像:D:\UnderTest\wavtester.wav.在这个字符串中,我想知道最后一次出现的\字符的索引(目标是获取表示的文件的名称String),所以我尝试使用该方法:
int x = nameOfAudioFile.lastIndexOf('\');
Run Code Online (Sandbox Code Playgroud)
但是我收到了与此声明相对应的错误说: unclosed character literal
这是一个小代码,可以一次比较3个变量.我比较了两个代码.
第一
#include <iostream>
int main() {
if( 8 > 7 > 6) std::cout << "true";
else std::cout << "false";
std::cout << "\n";
std::cout << (8 < 9);
std::cout << "\n";
system("pause");
}
// output :
/* false
* 1
*/
Run Code Online (Sandbox Code Playgroud)
第二
#include <iostream>
int main() {
if( 8 > (7 > 6) ) std::cout << "true"; // with brackets
else std::cout << "false";
std::cout << "\n";
std::cout << (8 < 9);
std::cout << "\n";
system("pause");
}
// output : …Run Code Online (Sandbox Code Playgroud) import java.util.*;
class next {
public static void main( String args[] ) {
String elements[] = { "Suhail" , "Shadow" , "Stars" };
Set s = new HashSet( Arrays.asList( elements ) );
Iterator i = s.iterator();
while( i.hasNext() ) {
System.out.println( i.next() );
}
}
}
Run Code Online (Sandbox Code Playgroud)
接下来的输出是:
Stars
Shadow
Suhail
Run Code Online (Sandbox Code Playgroud)
为什么我先打印最后一个元素?我期待输出suhail , shadow , stars
_以下问题的以下程序给出了一系列例外Exception in thread "main" java.lang.StackOverflowError
at testing_package.Compute.factorial(Compute.java:105)我不明白为什么会出现此错误.
问题:N个男孩和M个女孩正在从剧院学习表演技巧.为了表演,他们需要组成一组P演员,其中包含不少于4个男孩和不少于1个女孩.剧院要求你写一个程序,告诉他们组的形成方式.注意:组成应该是唯一的,而不是组成的顺序.
import java.io.*;
class Compute {
private static int NFact;
private static int N_Minus_R_Fact;
private static int RFact;
private static int fact=0;
public static int readTheStrengthOfGroup() {
int strengthOfGroup=0;
try {
System.out.println("Enter the strength of group : ");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String read = reader.readLine();
strengthOfGroup = Integer.parseInt(read);
} catch(Exception exc) {
System.out.println(exc);
}
return strengthOfGroup;
}
public static int readTheNumberOfBoys() {
int boysToParticipate=0;
try {
System.out.println("Enter …Run Code Online (Sandbox Code Playgroud) if即使我填写了text-field和password字段,以下函数的语句也不会执行.该alert函数在if语句之前工作正常但alertif语句之后的函数永远不起作用.
这是功能:
<script type="text/javascript">
function CheckForMissingFields() {
alert("before if statement");
if(document.getElementById("username").length != 0 && document.getElementById("password").length != 0) {
document.getElementByName("SignInButton").disabled = 'false';
alert("inside if statement");
}
alert("outside if statement");
}
Run Code Online (Sandbox Code Playgroud)
最初,按钮的状态SignIn被禁用.我希望在完成两个字段时启用它.if声明从未奏效的原因是什么?
以下是相应的HTML登录代码段:
<ul> <form method="post" action="#">
<li> <input type="text" id="username" value="Username or Email" size="25" name="UserID" onfocus="emptyTextField()" /> </li>
<li> <input type="password" id="password" value="password" size="25" name="UserPassword" onfocus="emptyPasswordField()" />
<center><input type="submit" value="sign-in" style="font-size:20px" name="SignInButton" disabled="true"/> </center>
</li>
</form>
</ul>
Run Code Online (Sandbox Code Playgroud) 当我执行以下代码时:
<script type="text/javascript">
function UploadMessage() {
<%! String message = null;
boolean AttemptToUploadFile = false;
%>
<%
message = (String)request.getAttribute("SuccessMessage");
if(message != null) {
%>
alert("File Successfully Uploaded !");
<% } %>
<% else if((Boolean)request.getAttribute("UploadAttempt")) { %>
alert("Unable to upload file");
<%}%>
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
media/work documents/UnderTest/NetbeansCurrent/ProjectSnippets/build/generated/src/org/apache/jsp/portfolio_005fone_jsp.java:252: error: 'else' without 'if'
else if((Boolean)request.getAttribute("UploadAttempt")) {
1 error
Run Code Online (Sandbox Code Playgroud)
错误说if没有,else但我已经else立即放置if.那为什么错误?
我正在尝试使用时连接到derby数据库Tomcat.我尝试通过servlet来做到这一点.但我无法连接并获得以下异常:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
at org.apache.naming.NamingContext.lookup(NamingContext.java:803)
at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at servlets.servlet_1.doGet(servlet_1.java:21) //---> I have marked this line in the below servlet
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
at java.lang.Thread.run(Thread.java:619)
Run Code Online (Sandbox Code Playgroud)
当以下servlet运行时:
package servlets;
import …Run Code Online (Sandbox Code Playgroud) 在下面的程序中,我尝试将结构传递给函数.但我得到错误,我不明白为什么.我在这个程序中犯了什么错误?
我gcc用来编译这个c程序.
#include <stdio.h>
struct tester {
int x;
int *ptr;
};
void function(tester t);
int main() {
tester t;
t.x = 10;
t.ptr = & t.x;
function(t);
}
void function(tester t) {
printf("%d\n%p\n",t.x,t.ptr);
}
Run Code Online (Sandbox Code Playgroud)
错误:
gcc tester.c -o tester
tester.c:8:15: error: unknown type name ‘tester’
tester.c: In function ‘main’:
tester.c:12:2: error: unknown type name ‘tester’
tester.c:13:3: error: request for member ‘x’ in something not a structure or union
tester.c:14:3: error: request for member ‘ptr’ in …Run Code Online (Sandbox Code Playgroud) 我创建了一个名为greet的过程:
create procedure greet(message in char(50))
as
begin
dbms_output.put_line('Greet Message : ' || message);
end;
Run Code Online (Sandbox Code Playgroud)
程序编译成功,但当我尝试将其称为:
execute greet('Hey ! This is a self created procedure :)');
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
execute greet('Hey ! This is a self created procedure :)')
Error report:
ORA-06550: line 1, column 7:
PLS-00905: object SUHAIL.GREET is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
Run Code Online (Sandbox Code Playgroud)
它有什么错误?我为什么要这个?
注意:'suhail'是连接到oracle服务器的当前用户的名称