小编Gif*_*ary的帖子

如何在java中进行联合,交叉,差异和反转数据

我想在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)

java

50
推荐指数
4
解决办法
9万
查看次数

如何使用oAuth从twitter获取用户电子邮件地址?

可能重复:
在使用OAuth验证她的Twitter身份后,有没有办法获取用户的电子邮件ID?

使用oAuth我能够成功登录并将其转发回我的PHP应用程序.

如何获取经过身份验证的人的电子邮件地址?在这一点上,我只有一个经过验证的oAuth.

你能指导我一个教程吗?

twitter oauth

30
推荐指数
1
解决办法
4万
查看次数

使用升序将元素插入ArrayList,并且没有重复元素

我有一个家庭作业,我需要插入或添加新的元素ArrayList<Interger>与以下条件:

  1. 元素必须按升序排列.

  2. 没有重复的元素ArrayList<Integer>

  3. 插入方法在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)

java arraylist

12
推荐指数
2
解决办法
5万
查看次数

11
推荐指数
3
解决办法
4万
查看次数

在.txt文件中查找所有字符串"the"

这是我的代码:

// 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)

java

11
推荐指数
1
解决办法
4万
查看次数

PHP和AJAX中的cookie问题

我在脚本上遇到一些问题,我使用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)

哪里不对了?

php cookies ajax jquery

11
推荐指数
1
解决办法
1万
查看次数

Nuxt.js 刷新 url 找不到 404

我的 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 个位置,我认为生成所有位置页面是不可能的。

请告诉我该怎么办。

node.js vue.js nuxt.js

9
推荐指数
3
解决办法
6487
查看次数

Web浏览器地理定位如何工作?

我想知道geolocation如何在Google Chrome或Firefox等网络浏览器中运行?

我可以访问此网站http://html5demos.com/geo,当我允许浏览器发送我的位置时,它会显示我当前的位置.

但是,当我将该URL发送给我的朋友进行测试时,它并不适用于所有这些网址.地理位置如何工作以及如何实施以获得正确的位置?

geolocation

7
推荐指数
2
解决办法
2万
查看次数

Vuejs 使用 postmessage 从 iframe 接收事件

根据此主题从 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 获取消息?

谢谢

javascript vue.js

6
推荐指数
1
解决办法
1万
查看次数

laravel excel读取文件而不导入数据库

我正在使用这个库来管理 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)

php laravel

5
推荐指数
1
解决办法
2435
查看次数

标签 统计

java ×3

php ×3

vue.js ×2

ajax ×1

arraylist ×1

cookies ×1

geolocation ×1

image ×1

javascript ×1

jquery ×1

laravel ×1

node.js ×1

nuxt.js ×1

oauth ×1

twitter ×1

url ×1