Questions tagged [addition]

Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign (+).

Addition is a mathematical operation that represents combining collections of objects together into a larger collection. It is signified by the plus sign (+).

It is commutative, meaning that order does not matter, and it is associative, meaning that when one adds more than two numbers, order in which addition is performed does not matter.

(Wikipedia)

5629 questions
1572
votes
66 answers

How can I concatenate two arrays in Java?

I need to concatenate two String arrays in Java. void f(String[] first, String[] second) { String[] both = ??? } Which is the easiest way to do this?
Antti Kissaniemi
  • 18,944
  • 13
  • 54
  • 47
267
votes
7 answers

Add a column to a table, if it does not already exist

I want to write a query for MS SQL Server that adds a column into a table. But I don't want any error display, when I run/execute the following query. I am using this sort of query to add a table ... IF EXISTS ( SELECT * FROM …
Tavousi
  • 14,848
  • 18
  • 51
  • 70
252
votes
11 answers

momentJS date string add 5 days

i have a start date string "20.03.2014" and i want to add 5 days to this with moment.js but i don't get the new date "25.03.2014" in the alert window. here my javascript Code: startdate = "20.03.2014"; var new_date = moment(startdate,…
Dave
  • 2,815
  • 5
  • 19
  • 22
251
votes
4 answers

Can I split an already split hunk with git?

I've recently discovered git's patch option to the add command, and I must say it really is a fantastic feature. I also discovered that a large hunk could be split into smaller hunks by hitting the s key, which adds to the precision of the…
greg0ire
  • 22,714
  • 16
  • 72
  • 101
244
votes
4 answers

How to add hours to current time in python

I am able to get the current time as below: from datetime import datetime str(datetime.now())[11:19] Result '19:43:20' Now, I am trying to add 9 hours to the above time, how can I add hours to current time in Python?
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313
191
votes
12 answers

How to add an integer to each element in a list?

If I have list=[1,2,3] and I want to add 1 to each element to get the output [2,3,4], how would I do that? I assume I would use a for loop but not sure exactly how.
user1212818
156
votes
9 answers

Git: add vs push vs commit

What is the difference between git add, push and commit? Just a little confused coming from SVN, where "update" will 'add' stuff, and commit does a "push" and will 'add' as well There are all different functions within git. Hoping for some…
CQM
  • 42,592
  • 75
  • 224
  • 366
145
votes
9 answers

What is the difference between the add and offer methods in a Queue in Java?

Take the PriorityQueue for example http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E) Can anyone give me an example of a Queue where the add and offer methods are different? According to the Collection doc, the add method…
Finbarr
  • 31,350
  • 13
  • 63
  • 94
132
votes
9 answers

What's the difference between array_merge and array + array?

A fairly simple question. What's the difference between: $merged = array_merge($array1, $array2); and $merged = $array1 + $array2; ?
The Pixel Developer
  • 13,282
  • 10
  • 43
  • 60
130
votes
3 answers

Add a new item to recyclerview programmatically?

I'm still trying to get my head around recyclerview. I have an arraylist, that I use to initialize a recycler view with. How can I add new items to the recycler view post setting an adapter and layoutmanager? private void initData() { …
Shubham Kanodia
  • 6,036
  • 3
  • 32
  • 46
118
votes
9 answers

Add onclick event to newly added element in JavaScript

I have been trying to add onclick event to new elements I added with JavaScript. The problem is when I check document.body.innerHTML I can actually see the onclick=alert('blah') is added to the new element. But when I click that element I don't see…
Desolator
  • 22,411
  • 20
  • 73
  • 96
116
votes
11 answers

How to force JS to do math instead of putting two strings together

I need javascript to add 5 to an integer variable, but instead it treats the variable as a string, so it write out the variable, then add 5 onto the end of the "string". How can I force it to do math instead? var dots =…
Sean
  • 8,401
  • 15
  • 40
  • 48
114
votes
9 answers

How to add new column to MYSQL table?

I am trying to add a new column to my MYSQL table using PHP. I am unsure how to alter my table so that the new column is created. In my assessment table I have: assessmentid | q1 | q2 | q3 | q4 | q5 Say I have a page with a textbox and I type q6…
Steven Trainor
  • 1,255
  • 4
  • 13
  • 20
92
votes
8 answers

In Java, is the result of the addition of two chars an int or a char?

When adding 'a' + 'b' it produces 195. Is the output datatype char or int?
orange
  • 5,297
  • 12
  • 50
  • 71
91
votes
4 answers

How to combine the sequence of objects in jq into one object?

I would like to convert the stream of objects: { "a": "green", "b": "white" } { "a": "red", "c": "purple" } into one object: { "a": "red", "b": "white", "c": "purple" } Also, how can I wrap the same sequence into an array? [ { …
Jennifer M.
  • 1,398
  • 1
  • 9
  • 11
1
2 3
99 100