我想知道Java是否有这样的形式:
new Object().methodOne("This is the first method").methodTwo("Second attached method");
new String("Hello World ").TrimEnd().Split(' ');
Run Code Online (Sandbox Code Playgroud)
谢谢
当我单击触发editUser(User)方法的命令按钮或在我的辅助bean中触发editClient(User)方法的方法时,不再调用这些方法.它以前工作过,但现在什么也没有.页面重新加载.
这可能有什么问题?
这是我的观点:
<p:accordionPanel activeIndex="#{userManagement.activeOverviewTab}" id="overview" rendered="#{loginControl.isAllowedForClientUserCreation()}">
<p:tab title="#{text.tabClients}" rendered="#{loginControl.isAllowedForUserManagement()}">
<h:form id="clientForm">
<p:dataTable value="#{userManagement.clientUsers}" var="clientUser" paginator="true" rows="5" id="clientTable">
<p:column><f:facet name="header"><h:outputText value="#{text.colClientName}"/></f:facet><h:outputText value="#{clientUser.client.clientName}"/></p:column>
<p:column><f:facet name="header"><h:outputText value="#{text.colClientEmail}"/></f:facet><h:outputText value="#{clientUser.client.email}"/></p:column>
<p:column><f:facet name="header"><h:outputText value="#{text.colClientJobLayout}"/></f:facet><h:outputText value="#{clientUser.client.reportLayout}"/></p:column>
<p:column><f:facet name="header"><h:outputText value="#{text.colUsersLogin}"/></f:facet><h:outputText value="#{clientUser.login}"/></p:column>
<p:column><f:facet name="header"><h:outputText value="#{text.colUsersPassword}"/></f:facet><h:outputText value="#{clientUser.password}"/></p:column>
<p:column><f:facet name="header"><h:outputText value="#{text.colUsersAction}"/></f:facet>
<p:commandLink onclick="clientDlg.show()">
<h:graphicImage name="icons/pencil.png" title="#{text.editClientUser}" />
</p:commandLink>
<p:dialog header="#{text.editClientUser}" widgetVar="clientDlg" modal="true" resizable="false" width="350" height="190" showEffect="slide" hideEffect="explode">
<h:form id="customerEditForm">
<p:growl id="clientUserMessages"/>
<br/>
<p:panelGrid columns="2" columnsClasses="odd, even">
<h:outputLabel value="#{text.colClientName}"/><h:inputText value="#{clientUser.client.clientName}" />
<h:outputLabel value="#{text.colClientEmail}"/><h:inputText value="#{clientUser.client.email}" />
<h:outputLabel value="#{text.colClientJobLayout}"/><h:inputText value="#{clientUser.client.reportLayout}" />
<h:outputLabel value="#{text.colUsersLogin}"/><h:inputText …Run Code Online (Sandbox Code Playgroud) 我曾经使用iOS,但我没有得到这个所有方法有什么区别,
我应该使用哪种语法来调用MehodName?
(1) [self MehodName];
(2) [self performSelector:@selector(MehodName) withObject:nil];
(3) [self performSelectorInBackground:@selector(MehodName) withObject:nil];
(4) [self performSelectorOnMainThread:@selector(MehodName) withObject:nil waitUntilDone:YES];
(5) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
(unsigned long)NULL), ^(void) {
[self MehodName];
});
(6) dispatch_sync(dispatch_get_main_queue(), ^{
[self MehodName];
});
Run Code Online (Sandbox Code Playgroud)
请提前帮助和谢谢.
我想测试我的方法在无法模拟的同一类中调用了另一个方法。
例:
public void methodToTest(){
//other stuff to test that can be mocked
someClassICanMock.doSomething();
//method within same class that cannot be mocked
methodFromSameClassIWantToVerify();
}
Run Code Online (Sandbox Code Playgroud)
我如何使用a verify来检查我的测试方法methodFromSameClassIWantToVerify();?
编辑:不是重复的,因为我专门指的是如何使用Mockito对此进行测试。
这是一些代码段.我已经测试了列出的方法并且它们正常工作,但是当我运行并测试此方法(countLOC)时,它似乎只是初始化具有实例方法call(i = self.countBlankLines())的第一个变量.有人知道我明显错过的明显原因吗?
def countLOC(self):
i = self.countBlankLines()
j = self.countDocStringLines()
k = self.countLines()
p = self.countCommentLines()
return k-i-j-p
Run Code Online (Sandbox Code Playgroud)
返回-3因为countBlankLines()返回3(正确).但是,它应该返回37 as countDocStringLines()= 6和countCommentLines()= 4而countLines()= 50.感谢.
阅读本文后,我发现了几种调用方法的方法.
致电方法:
public static void SendData(string value) { }
Run Code Online (Sandbox Code Playgroud)
呼叫:
delegate void MyDelegate(string value);
//Slow method - NOT RECOMMENDED IN PRODUCTION!
SendData("Update");
// Fast method - STRONGLY RECOMMENDED FOR PRODUCTION!
MyDelegate d = new MyDelegate(SendData);
d.BeginInvoke("Update", null, null);
Run Code Online (Sandbox Code Playgroud)
这是真的吗?它更快吗?
Action send = () => Send("Update");
send();
Run Code Online (Sandbox Code Playgroud)
或许这个?
我需要将一个方法调用到具有最高性能的SQL CLR触发器中,因此即使很小的速度增加也是有意义的.
嘿伙计们,我对OOP和c ++都很新,所以请耐心等待.
我正在尝试定义一个类,它的功能,然后使用它们.我会展示到目前为止我所遇到的以及我遇到错误的地方.
在名为"account.h"的文件中,我有:
#include <iostream>
#include <string>
using namespace std;
class Account{
string fname;
string lname;
string sinnum;
string accttype;
int numtrans;
double balance;
public:
Account(string,string,string,string);
double DepositAmt(double);
double WithdrawAmt(double);
void PrintStatement();
void getFinalBalance();
};
Run Code Online (Sandbox Code Playgroud)
在一个名为"account.cpp"的文件中,我有:
Account::Account(string firstname, string lastname, string sinnumber, string acc
{
fname = firstname;
lname = lastname;
sinnum = sinnumber;
accttype = accounttype;
numtrans = 0;
balance = 0;
}
double Account::DepositAmt(double deposit)
{
balance = balance + deposit;
return balance;
}
double Account::WithdrawAmt(double withdraw) …Run Code Online (Sandbox Code Playgroud) 那么文件"MyStore.obj"和我下载的表一起附上了.我应该阅读这个文件的内容,这是与内容的顺序给出的.我可以确定它是否存在?因为你可以看到我尝试使用方法exists()但它没有用
import java.io.*;
public class sheet{
public static void main(String[]args){
try{
FileInputStream fis=new FileInputStream("MyStore.obj");
if(("MyStore.obj").exists()==false) //what can i do to fix this?
throw new FileNotFoundException("file doesn't exist");
ObjectInputStream ois=new ObjectInputStream(fis);
int numOfStorageDevice=ois.readInt();
int numOfComputerGames=ois.readInt();
StorageDevice [] sd=new StorageDevice[numOfStorageDevice];
for(int n=0;n<numOfStorageDevice;n++)
sd[n]=(StorageDevice)ois.readObject();
ComputerGame []cg=new ComputerGame[numOfComputerGames];
for(int m=0;m<numOfComputerGames;m++)
cg[m]=(ComputerGame)ois.readObject();
File file=new File("Result.txt");
FileOutputStream fos=new FileOutputStream(file);
PrintWriter pr=new PrintWriter(fos);
for(int i=0;i<numOfStorageDevice;i++){
String model= sd[i].getmodel();
/*and in the methodcall sd[i].getmodel() it keeps telling that
the symbol cannot be found but i'm sure that the …Run Code Online (Sandbox Code Playgroud) 在学习Java Generics参数化时,我想到了这段代码:
public interface Comparable<T> {
public int compareTo(T o);
}
public static <T extends Comparable<T>> int countGreaterThan(T[] anArray, T elem) {
int count = 0;
for (T e : anArray)
if (e.compareTo(elem) > 0)
++count;
return count;
}
Run Code Online (Sandbox Code Playgroud)
我想测试它,所以我写了这个:
Integer[] iArray = new Integer[10];
for (int i=0; i<10; i++){
iArray[i] = new Integer(i);
}
int a = countGreaterThan(iArray, Integer.valueOf(5));
Run Code Online (Sandbox Code Playgroud)
但是在调用方法时,编译器在最后一行给出了错误消息countGreaterThan:
The method countGreaterThan(T[], T) in the type Main is not applicable for the arguments (Integer[], Integer)
Run Code Online (Sandbox Code Playgroud)
我错过了一些明显的东西吗
如何在下面的例子中getRequestDispatcher("xxx")调用getServletContext()?这样的调用程序如何工作?请给我一个关于这个背景的清晰图片.
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/index.jsp");
dispatcher.include(request, response);
Run Code Online (Sandbox Code Playgroud) 我必须在java swing actionperformed方法中调用一个方法.但是当我点击按钮时没有任何反应.如何解决这个问题呢?
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
hellocalled();
}
}
Run Code Online (Sandbox Code Playgroud) method-call ×12
java ×6
c# ×3
.net ×1
arguments ×1
c++ ×1
delegates ×1
file ×1
invoke ×1
java-io ×1
jsf ×1
jsp ×1
lambda ×1
methods ×1
mockito ×1
objective-c ×1
parameters ×1
primefaces ×1
python ×1
servlets ×1
swing ×1
syntax ×1
unit-testing ×1
verify ×1