我想通过设置标志并在整个脚本中查看数据来输出PowerShell脚本中的变量和值.
我该怎么做?
例如,PowerShell与以下PHP代码等效的是什么?
echo "filesizecounter: " . $filesizecounter
Run Code Online (Sandbox Code Playgroud) 我来自php背景,在php中,有一个array_size()函数可以告诉你数组中有多少元素被使用.
String[]数组有类似的方法吗?谢谢.
如何将值从纳秒转换为秒?
这是代码段:
import java.io.*;
import java.util.concurrent.*;
..
class Stamper {
public static void main (String[] args) {
long start = System.nanoTime();
//some try with nested loops
long end = System.nanoTime();
long elapsedTime = end - start;
System.out.println("elapsed: " + elapsedTime + "nano seconds\n");
//convert to seconds
TimeUnit seconds = new TimeUnit();
System.out.println("which is " + seconds.toSeconds(elapsedTime) + " seconds");
}}
Run Code Online (Sandbox Code Playgroud)
错误是
Stamper.java:16: enum types may not be instantiated.
Run Code Online (Sandbox Code Playgroud)
这是什么意思?
在计算速度的另一个Bruce Eckels练习中,v = s / ts和t是整数.我如何制作它以便分裂曲柄浮出水面?
class CalcV {
float v;
float calcV(int s, int t) {
v = s / t;
return v;
} //end calcV
}
public class PassObject {
public static void main (String[] args ) {
int distance;
distance = 4;
int t;
t = 3;
float outV;
CalcV v = new CalcV();
outV = v.calcV(distance, t);
System.out.println("velocity : " + outV);
} //end main
}//end class
Run Code Online (Sandbox Code Playgroud) 如何将选定的字段值存储到查询中的变量中并在更新语句中使用它?
这是我的程序:
我正在编写一个SQL Server 2005 T-SQL存储过程,它执行以下操作:
这是我的代码:
DECLARE @tmp_key int
DECLARE @get_invckey cursor
set @get_invckey = CURSOR FOR
select invckey from tarinvoice where confirmtocntctkey is null and tranno like '%115876'
OPEN @get_invckey
FETCH NEXT FROM @get_invckey into @tmp_key
WHILE (@@FETCH_STATUS = 0)
BEGIN
SELECT c.PrimaryCntctKey as PrimaryContactKey
from tarcustomer c, tarinvoice i
where i.custkey = c.custkey and i.invckey = @tmp_key
UPDATE tarinvoice set confirmtocntctkey = PrimaryContactKey where invckey = @tmp_key …Run Code Online (Sandbox Code Playgroud) 我是一个新手Java编码器,我只是读取一个整数类的变量,可以在API中描述三种不同的方式.我有以下代码:
if (count.compareTo(0)) {
System.out.println(out_table);
count++;
}
Run Code Online (Sandbox Code Playgroud)
这是一个循环,只是输出out_table.
我的目标是弄清楚如何查看整数值count > 0.
我意识到这count.compare(0)是正确的方法吗?或者是count.equals(0)吗?
我知道这count == 0是不正确的.这是正确的吗?它的价值比较运算符在哪里count=0?
在另一个Bruce Eckel练习中,我编写的代码采用了一种方法并在另一个类中更改了值.这是我的代码:
class Big {
float b;
}
public class PassObject {
static void f(Letter y) {
y.c = 'z';
} //end f()
static void g(Big z) {
z.b = 2.2;
}
public static void main(String[] args ) {
Big t = new Big();
t.b = 5.6;
System.out.println("1: t.b : " + t.b);
g(x);
System.out.println("2: t.b: " + t.b);
} //end main
}//end class
Run Code Online (Sandbox Code Playgroud)
它抛出的错误是"可能会损失精确度".
PassObject.java:13: possible loss of precision
found: double
required : float z.b = 2.2
passobject.java:20: possible …Run Code Online (Sandbox Code Playgroud) 我猜我得到了这个错误,因为字符串试图对一个null值进行子串.但这".length() > 0"部分不会消除这个问题吗?
这是Java片段:
if (itemdescription.length() > 0) {
pstmt2.setString(3, itemdescription.substring(0,38));
}
else {
pstmt2.setString(3, "_");
}
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
java.lang.StringIndexOutOfBoundsException: String index out of range: 38
at java.lang.String.substring(Unknown Source)
at MASInsert2.itemimport(MASInsert2.java:192)
at MASInsert2.processRequest(MASInsert2.java:125)
at MASInsert2.doGet(MASInsert2.java:219)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:835)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:640)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1286)
at java.lang.Thread.run(Unknown Source)
Run Code Online (Sandbox Code Playgroud) 在Linux环境中开始学习PostgreSQL管理和编程的最佳位置是什么?什么网站是最推荐,简洁和易于学习的教程?
我已经熟悉了使用SQL Server和MySQL的ANSI SQL; 但是,我以前从未接触过PostgreSQL.您可以给予的任何方向表示赞赏.
我正在试图弄清楚如何连续读取文件,一旦添加了新行,就输出该行.我正在使用一个睡眠线程,但它似乎只是吹过整个文件并退出程序.
我有什么错误吗?
这是我的代码:
import java.io.*;
import java.lang.*;
import java.util.*;
class jtail {
public static void main (String args[])
throws InterruptedException, IOException{
BufferedReader br = new BufferedReader(
new FileReader("\\\\server01\\data\\CommissionPlanLog.txt"));
String line = null;
while (br.nextLine ) {
line = br.readLine();
if (line == null) {
//wait until there is more of the file for us to read
Thread.sleep(1000);
}
else {
System.out.println(line);
}
}
} //end main
} //end class jtail
Run Code Online (Sandbox Code Playgroud)
提前致谢
更新:我已经改变了行"while(br.nextLine){"只是"while(TRUE){"