我想在Java中进行联合,交叉,差异和反向操作.
首先,我有2个实例 ArrayList<Integer>
a = [0,2,4,5,6,8,10]
b = [5,6,7,8,9,10]
Run Code Online (Sandbox Code Playgroud)
工会乙应该回来 c = [0,2,3,4,5,6,7,8,9,10]
交叉b应该返回 c = [5,8,10]
应该返回一个defference b c = [0,2,3,4]
相反 a = [10,8,6,5,4,2,0]
像这样的东西.
如何在Java中实现该方法?
更新:我必须从这个模板开始:
package IntSet;
import java.util.ArrayList;
import java.util.Collection;
public class IntSet {
private ArrayList<Integer> intset;
public IntSet(){
intset = new ArrayList<Integer>();
}
public void insert(int x){
intset.add(x);
}
public void remove(int x){
//implement here
intset.indexOf(x);
}
public boolean member(int x){
//implement here
return true;
}
public IntSet intersect(IntSet a){
//implement here
return …
Run Code Online (Sandbox Code Playgroud) 使用oAuth我能够成功登录并将其转发回我的PHP应用程序.
如何获取经过身份验证的人的电子邮件地址?在这一点上,我只有一个经过验证的oAuth.
你能指导我一个教程吗?
我有一个家庭作业,我需要插入或添加新的元素ArrayList<Interger>
与以下条件:
元素必须按升序排列.
没有重复的元素ArrayList<Integer>
插入方法在O(n)次运行.
这是我在添加新元素之前检查重复元素的insert方法.
public void insert(int x){
//effect: Check duplicate elements if not x to the elements;
boolean found = false;
if(super.size()!=0){
for(int i=0; i<super.size(); i++){
if(super.get(i)==x){
found = true;
}
}
}
if(found){ return; }
else{ super.add(x); }
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做?谢谢.
加成
这是我的类名InSetExtra
public class IntSetExtra extends ArrayList<Integer> {
private static final long serialVersionUID = 1L;
public IntSetExtra(){
super();
}
public void insert(int x){
//effect: Check duplicate elements if not …
Run Code Online (Sandbox Code Playgroud) 我有一些问题.
我需要检查网址是否为图片网址?我怎样才能做到这一点?
示例:如果我把http://www.google.com/放在不是图片网址.
但如果我把http://www.google.com/profiles/c/photos/private/AIbEiAIAAABECK386sLjh92M4AEiC3ZjYXJkX3Bob3RvKigyOTEzMmFmMDI5ODQ3MzQxNWQxY2VlYjYwYmE2ZTA4YzFhNDhlMjBmMAEFQ7chSa4PMFM0qw02kilNVE1Hpw或http://www.hoax-slayer.com/images/worlds-strongest-dog.jpg是为图像的URL.
这是我的代码:
// Import io so we can use file objects
import java.io.*;
public class SearchThe {
public static void main(String args[]) {
try {
String stringSearch = "the";
// Open the file c:\test.txt as a buffered reader
BufferedReader bf = new BufferedReader(new FileReader("test.txt"));
// Start a line count and declare a string to hold our current line.
int linecount = 0;
String line;
// Let the user know what we are searching for
System.out.println("Searching for " + stringSearch + " …
Run Code Online (Sandbox Code Playgroud) 我在脚本上遇到一些问题,我使用PHP和jquery来创建登录系统.
首先,我有PHP页面包含登录表单.当用户点击提交时,我使用jquery将数据发送到服务器
$.post('server_login.php', {username:username.val(), password:password.val()}, function(data){
alert(data);
});
Run Code Online (Sandbox Code Playgroud)
在server_login.php中我有做登录用户的功能.
if($_POST['username']=='username' && $_POST['password']=='1234'){
$expire = time() + 60*60*24*30; //1 month expired.
setcookie("user_id", $_POST['username'], $expire);
echo true;
}
Run Code Online (Sandbox Code Playgroud)
和jquery在我的登录页面上提醒"1".
问题是,当我刷新我的网站并收回cookie时,它没有告诉我.
print_r($_COOKIE);
Run Code Online (Sandbox Code Playgroud)
哪里不对了?
我的 nuxt.js 项目有一个问题。
我创建动态页面,如https://samplesite.com/place/{place_id}
place_id 动态值。(我的数据库中有大约 4,000 多个位置)
在我运行npm run generate
并获取 /dist 文件夹后,我将此文件夹推送到亚马逊 EC2。
一切正常,当我在 /place/{place_id} 页面点击索引页面上的一个赞时,网站显示位置信息。
但是当我在网络浏览器上按下刷新按钮时,页面 /place/{place_id} 显示 404 not found。
你有解决这个问题的方法吗?
我在 nuxt.js 网站上读到,他们说我需要生成动态页面,但我的位置大约有 4,000 个位置,我认为生成所有位置页面是不可能的。
请告诉我该怎么办。
我想知道geolocation如何在Google Chrome或Firefox等网络浏览器中运行?
我可以访问此网站http://html5demos.com/geo,当我允许浏览器发送我的位置时,它会显示我当前的位置.
但是,当我将该URL发送给我的朋友进行测试时,它并不适用于所有这些网址.地理位置如何工作以及如何实施以获得正确的位置?
根据此主题从 iframe 调用父窗口函数
假设 iframe 可以将数据发送回父窗口。
现在我使用vuejs实现它,我的代码是
<v-card>
<iframe :src="url" style="width:100%; height:100vh; border:0px;"></iframe>
</v-card>
Run Code Online (Sandbox Code Playgroud)
在 iframe url 中,我将脚本放入
$('#uploadbtn').bind("click",function(){
window.parent.postMessage({
'func': 'parentFunc',
'message': 'Message text from iframe.'
}, "*");
});
Run Code Online (Sandbox Code Playgroud)
当用户单击按钮时,它会将消息发送回父级(vue 组件)。
我的问题是如何在 VueJS 端编写代码以从 iframe 获取消息?
谢谢
我正在使用这个库来管理 laravel 项目上的 excel 文件(https://docs.laravel-excel.com/3.1/getting-started/)
一旦我从本地上传并作为 JSON 返回,我想只读 excel 文件。
我在控制器中的代码是
$excel = $request->file('excel');
$array = Excel::import(new ProductsImport, $excel);
Run Code Online (Sandbox Code Playgroud)
ProductsImport 文件在哪里
<?php
namespace App\Imports;
use App\Models\Product;
use Maatwebsite\Excel\Concerns\Importable;
use Maatwebsite\Excel\Concerns\ToModel;
class ProductsImport implements ToModel
{
use Importable;
/**
* @param array $row
*
* @return Products|null
*/
public function model(array $row)
{
//return $row;
return new Product([
'name' => $row[0],
'email' => $row[1]
]);
}
}
Run Code Online (Sandbox Code Playgroud)