几个月前,我的网站充满了通知错误,所以我现在正在尝试修复代码.我想有一些PHP更新.我不是那么聪明的PHP所以:
switch ( (isset($_GET['action'])) ) {
case "delete":
delete();
break;
}
Run Code Online (Sandbox Code Playgroud)
添加isset时这不起作用.
你不能在函数内使用isset吗?我真的不知道所以我问你那些了解这些事情的人.
干杯
我正在重新设计现有的课程.在这个类中,大约有400行while循环,它完成了大部分工作.循环的主体是if语句,变量赋值的雷区,并且在某个中间有一个"继续".循环的目的很难理解.
在伪代码中,这是我重新设计的地方:
/* Some code here to create the objects based on config parameters */
/* Rather than having if statements scattered through the loop I */
/* create instances of the appropriate classes. The constructors */
/* take a database connection. */
FOR EACH row IN mySourceOfData
int p = batcher.FindOrCreateBatch( row );
int s = supplierBatchEntryCreator.CreateOrUpdate( row, p );
int b = buyerBatchEntryCreator.CreateOrUpdate( row, p );
mySouceOfData.UpdateAsIncludedInBatch( p, s, b);
NEXT
/* Allow things to complete their last …Run Code Online (Sandbox Code Playgroud) 我目前正在使用本地应用程序,该应用程序可以访问SQL Server 2008 Express.我所做的是创建一个管理数据库上所有访问和操作的类(例如INSERT,DELETE等),但是这个类变得非常大,并且至少有40个方法.所以我的问题是:有没有办法重构这类课程?或者那样是正常的吗?
请帮助我理解这个程序的执行情况以及更广泛意义上适用的概念?解释线程/堆栈创建和销毁的说明将是有帮助的.
class Joining {
static Thread createThread(final int i, final Thread t1) {
Thread t2 = new Thread() {
public void run() {
System.out.println(i+1);
try {
t1.join();
} catch (InterruptedException ie) {
}
System.out.println(i+2);
}
};
System.out.println(i+3);
t2.start(); //1
System.out.println(i+4);
return t2;
}
public static void main(String[] args) {
createThread(10, createThread(20, Thread.currentThread()));
}
}
Run Code Online (Sandbox Code Playgroud) 我试图检查一个气泵是否可以自由使用&充满气体,然后我试图让那个泵成为汽车排队使用的泵.
Thread carThreads[]=new Thread[TOTAL_CARS];
try {
Pump pump1 = new Pump();
pump1.setName("pump1");
pump1.setFuelAmount(2000);
pump1.setState(0);
Pump pump2 = new Pump();
pump2.setName("pump2");
pump2.setFuelAmount(2500);
pump2.setState(0);
Pump chosenPump = new Pump();
if( pump1.getState()==0 && pump1.getFuelAmount()<0 ){
chosenPump = pump1;
System.out.println("Pump1 is free and has a fuel amount of: "
+ (pump1.getFuelAmount()) );
}
else if ( pump2.getState()==0 && pump2.getFuelAmount()<0 ){
chosenPump = pump2;
System.out.println("Pump2 is free and has a fuel amount of: "
+ (pump2.getFuelAmount()) );
}
//else{
// System.out.println("Must wait for the tanker. …Run Code Online (Sandbox Code Playgroud) 这吓了我一跳.以下测试失败; 循环结束时,我的值为9,而不是8.你能解释一下吗?
import junit.framework.TestCase;
public class TestDoWhile extends TestCase {
final int LIMIT = 8;
public void testDoWhile() throws Exception {
int i = 0;
do {
} while (i++ < LIMIT);
assertEquals(LIMIT, i);
}
}
Run Code Online (Sandbox Code Playgroud) 我需要在Oracle查询中对结果集中的最后7个字符进行RTRIM.这7个字符可以是任何东西; 空格,字母数字等......我不知道任何值的确切长度.
所以例如我想运行这样的东西
SELECT RTRIM (COl_A, (SELECT LENGTH (COL_A)-7) FROM TABLE_ONE;
Run Code Online (Sandbox Code Playgroud)
或替换等价物
SELECT REPLACE(COL_A, (SELECT LENGTH (COL_A)-7 FROM TABLE_ONE),'');
Run Code Online (Sandbox Code Playgroud)
我是否需要对SUBSTRING做些什么?
我知道如何删除/替换特定字符,但在处理未知字符时我遇到了麻烦.我已经看到了一些类似问题的例子,但它们似乎不必要地复杂......或者这需要比我想象的更深入的解决方案吗?
一如既往地感谢您的建议或提示.
在java中你可以有一个变量数组吗?
如果是的话语法是什么?
这是一个例子,如果你困惑:
varint[] ArrayOfVariablesThatAreInts = new varint[#]
Run Code Online (Sandbox Code Playgroud)
要么
var[] ArrayofVariables = new var[#]
Run Code Online (Sandbox Code Playgroud)
这是合法的吗?
java ×4
refactoring ×2
arrays ×1
c# ×1
concurrency ×1
if-statement ×1
oracle ×1
php ×1
sql ×1
variables ×1
while-loop ×1