I want to remove the last 3 characters of the string if the string has the same prefix and suffix. eg: the string is "systemsys", it should print system. Few inputs I am trying : incgoogleinc. Not working for this input  import java.util.*; public class Main {     public  static void main(String[] args) {     Scanner s = new Scanner(System.in);     String str = s.nextLine();     if(str.length() &gt; 3) {      if (str.startsWith(str.substring(0, 3)) == (str.substring(str.length()-3, str.length()-1))) {         System.out.println(str.substring(0, str.length()-3));         } else {         System.out.println(str); }}}   Not working for different inputs : mictestingmic, comwebsitecom
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
Time taken for collision We have three particles at the vertices of equilateral triangle of side $d$. At $t=0$ they start moving in such away that at all instant of time each of them has a speed $v$ towards adjacent one. We have to find the time after which they will collide. I know that you can solve this by calculating from reference frame of any one particle, but I want a way to solve this by calculating the total distance traveled first in ground frame and then dividing by speed. Additive function $T: \mathbb{R} \rightarrow \mathbb{R}$ that is not linear. A function $T:V \rightarrow W$ is additive if $T(x+y) = T(x) + T(y)$ for every $x, y \in V$. Prove that there exists an additive function $T: \mathbb{R} \rightarrow \mathbb{R}$ that is not linear.  My attempt: Let $T$ be the function $T: \mathbb{R}$ (over the field $\mathbb{Q}$) $\rightarrow \mathbb{R}$ (over the field $\mathbb{R}$). The set $\{1, \sqrt{2}\} \subseteq \mathbb{R}$ is linearly independent for the vector space $\mathbb{R}$ over $\mathbb{Q}$. Then, there must exist a linearly independent set $W \subseteq \mathbb{R}$ (over $\mathbb{Q}$) such that $\{1, \sqrt{2}\} \subseteq W \subseteq \text{span}(W) = \mathbb{R}$ (over $\mathbb{Q}$).  I have been told that the function defined as $T(1) = 1$ and $T(w) = 0$ for all $w \in \text{span}(W) \setminus \{1\}$ is additive but not linear, but I cannot see why this is? I can see why it is not linear, clearly $T(\sqrt{2} \cdot 1) = 0$ but $\sqrt{2} T(1) = \sqrt{2}$. But, why is $T$ additive? For example, $T(1+1) = T(2) =0$ but $T(1) + T(1) = 1+1 = 2$? Is there a mistake somewhere? Should “two weeks vacation” be written “two weeks’ vacation” with a possessive apostrophe? I’ve always understood that the phrase two weeks usually turns into two weeks’ when used as a modifier as in   I’m giving my two weeks’ notice.  I get two weeks’ vacation. (“two weeks’ holiday” for Brits)   with an apostrophe on the word weeks’, indicating that the vacation “belongs” to the weeks.   One way to explain this is the phrase “two weeks of vacation” being contracted to “two weeks’ vacation” – the vacation is “of” the weeks; that is, it is possessed by them.  But I’ve seen a lot of people omit the apostrophe in casual writing, and thinking about it, it seems plausible that the noun vacation would be plainly modified by the adjectival phrase two weeks.  But on the other hand, shouldn’t adjectival phrases be hypenated, namely two-weeks vacation?  Yet that seems wrong, too: the hyphenate should be singular, two-week vacation (like two-tone shoes) because .   touches on this (and references a good ) but doesn’t explain why the plural must be possessive in this case.   suggests that two weeks might be adverbial rather than adjectival, and thus resists being used attributively. But that still doesn’t quite explain this particular muddle of pluralization, possession, and attribution.  Given all this, why should “two weeks vacation” be written “two weeks’ vacation” with a possessive apostrophe? Why is the Yang–Mills existence and mass gap problem so fundamental? Ref:   Can anyone please explain why the Yang–Mills Existence and Mass Gap problem is so important / fundamental to contemporary mathematics (and, presumably, theoretical / mathematical physics)?  If possible, please include the following in your answer / response:  (1) Why the problem is so fundamental / important - for both mathematics and theoretical / mathematical physics; (2) How the solution to the problem would impact research in the above two fields; (3) (If applicable) What progress has been made so far in resolving it; (references to papers, books, other resources would be helpful).  I'm an upper-level undergraduate in theoretical physics, and so am seeking an answer / response at such level. ICS devices support creating backups using adb backup, and restoring them using adb restore. Using adb backup, one can select that everything should be backed up, or only a certain package.  However, adb restore lacks all the options of adb backup. When I call adb restore backup.ab, where backup.ab is only the backup of a single package, the phone shows me a warning dialog saying that all settings are going to be lost after restoring the backup. Is it true that restoring a single package backup wipes all data on the phone? If yes, is it somehow possible to restore a single package using adb restore? Solve $$u_{xx}-3u_{xt}-4u_{tt}=0$$ where $u(x,0)=x^2$ and $u_t(x,0)=e^x$.  My workings so far: I have factored the differential equation in the following way: $$(\delta_x-4\delta_t)(\delta_x+\delta_t)=0$$ where $\delta_x=\frac{\delta}{\delta x}$ etc. Now if we let $v$ be the solution to $(\delta_x+\delta_t)u$ then we have the following two equations: \begin{eqnarray*} (\delta_x+\delta_t)u=u_x+u_t=v\\ (\delta_x-4\delta_t)v=v_x-4v_t=0 \end{eqnarray*} Now for $v$ we simply find $$v=h(t+4x)$$ where $h$ is an arbitrary function of one variable. Now what remains is find $u$ such that $$u_x+u_t=h(t+4x)$$ I am stuck here, I thought about making a change of variables $\zeta=x+t$ and $\eta=x-t$ and thus using the product rule to show that $u_x=u_{\zeta}+u_{\eta}$ and $u_t=u_{\zeta}-u_{\eta}$ and thus $u_x+u_t=2u_{\zeta}$ and we need to solve $$u_{\zeta}=h(t+4x)$$ (I left out the factor 2 because $h$ is an arbitrary function). Do I simply integrate now and conclude $$u=f(\zeta)h(t+4x)+g(\eta)=f(x+t)h(t+4x)+g(x-t)$$ This seems wrong to me...  Some help would be greatly appreciated! CSS - Make divs align horizontally I have a container div with a fixed width and height, with overflow: hidden.  I want a horizontal row of float: left divs within this container. Divs which are floated left will naturally push onto the 'line' below after they read the right bound of their parent. This will happen even if the height of the parent should not allow this. This is how this looks:  ![Wrong][1] - removed image shack image that had been replaced by an advert  How I would like it to look:  ![Right][2] - removed image shack image that had been replaced by an advert  Note: the effect I want can be achieved by using inline elements &amp; white-space: no-wrap (that is how I did it in the image shown). This, however, is no good to me (for reasons too lengthy to explain here), as the child divs need to be floated block level elements. A Light is shone out the side window of a spaceship ( moving close to light speed ), will the light still travel at the speed of light in the B axis? The orbit of satellites around Earth eventually decays, or so I read. This is typically caused either by atmospheric drag, or by tides. I would assume most satellites have a limited service life in orbit. Hence the question - What is the typical orbital life of a satellite? How long before it's successor must be launched into orbit ?  EDIT: For instance, a weather satellite Can you identifiy this short about teenagers on a raft getting swallowed up by an oil slick? I have a Java process that opens a file using a FileReader. How can I prevent another (Java) process from opening this file, or at least notify that second process that the file is already opened? Does this automatically make the second process get an exception if the file is open (which solves my problem) or do I have to explicitly open it in the first process with some sort of flag or argument? To clarify: I have a Java app that lists a folder and opens each file in the listing for processing it. It processes each file after the other. The processing of each file consists of reading it and doing some calculations based on the contents and it takes about 2 minutes. I also have another Java app that does the same thing but instead writes on the file. What I want is to be able to run these apps at the same time so the scenario goes like this. ReadApp lists the folder and finds files A, B, C. It opens file A and starts the reading. WriteApp lists the folder and finds files A, B, C. It opens file A, sees that is is open (by an exception or whatever way) and goes to file B. ReadApp finishes file A and continues to B. It sees that it is open and continues to C. It is crucial that WriteApp doesn't write while ReadApp is reading the same file or vice versa. They are different processes. Arduino only works in root I've installed Arduino but as the title says, I can only upload with sudo. And yes my user is part of the dialout group so that's the weird thing.   Arduino did function before on my system. What could be wrong?  Output ls -l:  ls -l /dev/ttyUSB* crw-rw-rw- 1 root dialout 188, 0 apr  2 09:23 /dev/ttyUSB0 If $f(x)=x+\int_{0}^{1}[xy^2+x^2y]f(y)dy$ where $x$ and$y$ are independent variable.Find $f(x).$ How to 'sum' a standard deviation? I have a monthly average for a value and a standard deviation corresponding to that average. I am now computing the annual average as the sum of monthly averages, how can I represent the standard deviation for the summed average ?  For example considering output from a wind farm:  Month        MWh     StdDev January      927     333  February     1234    250 March        1032    301 April        876     204 May          865     165 June         750     263 July         780     280 August       690     98 September    730     76 October      821     240 November     803     178 December     850     250   We can say that in the average year the wind farm produces 10,358 MWh, but what is the standard deviation corresponding to this figure ? If $g \circ f$ is surjective, show that $f$ does not have to be surjective? Suppose $f: A \to B$ and $g: C \to D$ are functions, and that $B ⊆ C$.  I need to come up with an example where $g \circ f$ is surjective but $f$ is not. I'm confused on how exactly to do that, but I understand that to show something is surjective you have to have the range of the function equal to the codomain of the function. Here's my attempt:  So if $g(x) = x^2$ with a codomain of $ℝ$, and $f(x) = \sqrt{x}$ with a codomain of $ℝ$, then $g(f(x)) = (\sqrt{x})^2 = x$. Since the range of this function and codomain are the same, this is surjective.  But, since $f(x) = \sqrt{x}$, its range is only $[0, ∞)$, which is smaller than its codomain of $ℝ$, meaning $f$ is not surjective. How to create an index map of atlas features in QGIS 3? I realise that this question has been asked before (), however I am still unable to figure out how to create an index map of atlas features in the QGIS map composer.  Basically, I have a line and I have five atlas maps showing the extent of the line, and to show where which map corresponds to the line a I need five overviews on a map with numbers on them, which will look similar to below:    I've created five overviews, but as all of these must be set to correspond to the main map frame, all of them show the overview for which ever atlas feature is selected at the time, rather than appearing as separate index tiles.  Can anyone tell me where I am going wrong? Is there some way to get explorer to generate thumbnails without actually having to navigate and scroll through every folder?  All I could get was a command prompt script that would load an explorer window for all subfolders, however only images that were visible would have thumbnails created. To estimate the time for brute-force attack we need to compute keyspace size divided by hash rate, where the hash rate (hash/second) varies depending on the computer's capabilities.  The website  shows the hash rate for different computers.  Can you explain the following two confusing phenomena?   The hash rate decreases as the message size increases. Core i3 has a higher hash rate than Core i7 for SHAKE128. Story with multiple 'third planet' races I'm looking for the name and author of a novel (or possibly novella). I first read this in the seventies, and might be older than that. It might have been written for teenagers.  The story takes place on a planet inhabited by a primitive humanoid race, roughly stone age if I remember rightly. Visiting this planet is a small team from a more advanced race, also humanoid and with spacefaring technology (obviously!). They are either there to help or observe, no nefarious purposes. I think they are avoiding contact with the primitives, at least initially. It's explicitly mentioned that the planet they are visiting is the third one of a medium sized star, just like their own homeworld. Also orbiting round the planet is an even more advanced race, using high tech to remain hidden from both the others. They are observing the whole situation, and again its mentioned that this is a 'third planet', like their own homeworld.  I'm a little bit hazy on the rest of the plot, but I think the super-advanced race end up revealing themselves, even though they are not supposed to.  The story is told from the viewpoints of both the second and third races (maybe also the first, I forget)  EDIT: For the record it turns out my recollection was faulty, and the second race are indeed coming to the planet for nefarious purposes. And the planet is at the medieval stage, not stone age. Where should I start with Star Trek? (TV series only, not the movies) I haven't seen any of the stuff in the Star Trek franchise, except for one of the movies, and now I want to remedy the situation. I am not interested in the movies, just the TV series. However, since the show has many seasons, I am not interested in watching the show start to finish. So, where (i.e what series/season) should I start with? Do I really need to see the series in real-world chronological order?   Note: I am somewhat familiar with Star Trek, that is I know the basic premise - ships in space, with war between different space-faring sentient species.