class main{
public static void main(String[] args){
int[] array = new int[3];
array[0]=3;
array[1]=2;
array[2]=1;
System.out.println(<Integer>countGreaterThan(array,1));
}
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)
我在Java Documentation中得到了这个考试.当我编写扩展Comparable时,我怎么能告诉编译器什么是类型?我想我应该实例化T <T extends Comparable<T>>,但是怎么样?
我有一个 WordPress 网站,但它的注册页面(与 PayPal 集成)不是 WordPress 网站的一部分(其他一些开发人员正在这样做,它是用 PHP 编写的)。现在的问题是,每当我更改页脚或页眉(尤其是链接)中的某些位时,我都需要下载此外部 PHP 文件,更改那里的链接,然后再次上传。
这是一项乏味的任务,容易出错。他们不会让我在 WordPress 中处理注册表,所以我现在坚持这个工作流程。
我可以在他们的 PHP 文件中包含我的 WordPress 页脚和页眉,以便我们只使用同一个文件吗?
我有两个类,其中一个是另一个的子类,并且仅通过它包含一个额外的成员变量对于其父事实而不同.我没有使用默认构造函数,将对单个对象的引用作为constructors参数传递.我想是父的构造函数来检查这个对象,然后确定是否要构建父类(在大多数情况下)的实例或子类(在少数特殊情况时).
class Superclass
{
public:
Foo foo;
Superclass(MyObject* object)
{
foo = object->GetFoo();
if(object->CreateSubclass())
{
//Create Subclass
}
else
{
//Create Superclass
}
}
};
class Subclass : public Superclass
{
public:
Barr barr;
Subclass(MyObject* object)
{
barr = object->GetBarr();
}
};
Run Code Online (Sandbox Code Playgroud)
我知道工厂设计模式,但不想只为此拥有工厂对象.我宁愿将Superclass初始化内容复制到Subclass(看起来很糟糕),然后检查创建Superclass的每个点的对象,然后调用相应的构造函数:
Superclass* class;
if(object->CreateSubclass())
{
class = new Subclass(obj);
}
else
{
class = new Superclass(obj);
}
Run Code Online (Sandbox Code Playgroud)
这种事情是否可行,如果是这样,我将如何从Superclass构造函数中调用子类构造函数?我已经尝试过调用Subclass(object),但是我遇到了需要在另一个之前定义Superclass和Subclass的问题.
感谢您提供的任何建议.
如果我有这个索引:
if (isset($_GET['se'])) {
$se= $_GET['se'];
if (file_exists("{$se}.php")){
require("{$se}.php");
}
else {
require("page_error.php");
}
}
else {
require("page_error.php");
}
Run Code Online (Sandbox Code Playgroud)
像下面这样的链接不起作用:
$pwrurl = "http://example.com/login/?se=change_password?usermail=".$email."&usercode=".$linkHash;
Run Code Online (Sandbox Code Playgroud)
只有这样的东西http://example.com/login/?se=change_password才会被接受.
这可以解决吗?
public class Book {
String title;
public Book(String t) {
title = t;
}
}
public class Bookcomparator implements Comparator<Book> {
public int compare(Book one, Book two) {
return (one.title.compareTo(two.title));
}
}
public class TreesetTest {
public void go() {
Book b1 = new Book("How");
Book b2 = new Book("Remix");
Book b3 = new Book("Finding ");
Bookcomparator bc = new Bookcomparator();
TreeSet<Book> set = new TreeSet<Book>(bc);
set.add(b1);
set.add(b2);
set.add(b3);
System.out.println(set);
}
}
public class Test {
public static void main(String …Run Code Online (Sandbox Code Playgroud) 任何人都可以告诉我,如果我做错了什么?
public class Jafntekkijafnt
{
public static void main(String[] args)
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int c = Integer.parseInt(args[2]);
if (a == b) (b == c) (c == a) System.out.println("equal");
else System.out.println("not equal");
}
}
Run Code Online (Sandbox Code Playgroud)
这是java编程
我正在尝试使用三个整数创建一个程序,如果所有都相等则打印相等,如果不相等则不相等.
我知道它的第8行,但不知道如何正确.
我正在尝试做类似的事情:
{"semaforo":"icbc"},{"semaforo":"pepito"}
Run Code Online (Sandbox Code Playgroud)
我有以下代码:
for (Iterator it = semaforosMiddleware.iterator(); it.hasNext();) {
KeyMapMediciones semaforoMiddleware = (KeyMapMediciones) it.next();
jsonFamilias.append("{\"semaforo\":\"" + semaforoMiddleware.getAplicacion() + "\"}");
if (it.hasNext()) {
jsonFamilias.append(",");
}
}
Run Code Online (Sandbox Code Playgroud)
但我输出如下:
{"semaforo":"icbc"},{"semaforo":"pepito"},
Run Code Online (Sandbox Code Playgroud)
我不希望最后一个元素后面有最后一个逗号(",").我能做什么?
Eclipse不断给我以下错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
input cannot be resolved
The method If(boolean) is undefined for the type bai1DinhLuatCuLong
Syntax error, insert ";" to complete Statement
F cannot be resolved to a variable
Run Code Online (Sandbox Code Playgroud)
我不明白.我需要修理什么?为什么我不能使用这个If()功能?
我试过浏览Google和Bing,我已经仔细检查了我的Java示例书,但我无法解决这个问题.
import java.util.Scanner;
public class bai1DinhLuatCuLong
{
public static void main(String[] args)
{
System.out.print("Giá trì c?n tìm (F // q // r) : ");
char cantim = input.nextChar();
// HERE THIS IS WHERE I PUT THE IF STATEMENT !!!
If (cantim …Run Code Online (Sandbox Code Playgroud) 我正在尝试在字符串中获取最后三个字符.使用以下代码,我试图获取fname变量的最后三个字符,但我得到一个"方法长度(int)未定义类型字符串"错误:
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String number = request.getParameter("number");
String firstPart = lname.substring(0, 3);
String middlePart = fname.substring(0, fname.Length(3));
Run Code Online (Sandbox Code Playgroud) 这是我的代码:
public class LoginSql {
Conexion con = new Conexion();
con.conexionDB(); // error here <
}
Run Code Online (Sandbox Code Playgroud)
package con不存在但存在
public class Conexion {
public Connection conexionDB(){
Connection link = null;
return link
}
}
Run Code Online (Sandbox Code Playgroud)
我使用包示例
com.hi.pro
com.hi.pro.class
com.hi.pro.sql
Run Code Online (Sandbox Code Playgroud)
我有代码com.hi.pro.sql但没有工作

仅适用于app.java类中的com.hi.pro

我的if陈述不正常; 当我使用以下参数调用insert时,它不能正常工作100,50,20或10.
def insert():
credit = input("Please insert pennies untill you have payed 80p: ")
if False in [f == '100' or f == '50' or f == "20" or f == "10" for f in credit]:
print("You can only use, 100p, 50p, 20p or 10p! Try again...")
insert()
global coin
coin = (int(credit)) + coin
print (coin)
while coin < 80:
insert()
if coin >= 80:
again = input("Would you like your change[c], or another item[b]?")
if …Run Code Online (Sandbox Code Playgroud) java ×7
if-statement ×3
php ×2
arraylist ×1
c++ ×1
constructor ×1
generics ×1
hyperlink ×1
include ×1
inheritance ×1
list ×1
python ×1
query-string ×1
string ×1
substring ×1
syntax-error ×1
tostring ×1
wordpress ×1