So I just tried excluding String[] args from the main method
It compiled alright !
But JVM is showing an exception
Why did it compile when String[] args HAS to be included every time ?
What is going on here ? Why won't it show a compilation error ?
typing this made me think that may be compiler did not see it as THE main method ..is that so ?
Hello,
I'm sorry, but a while ago I wrote a piece of code that was so nice. And now I'm trying to remember it for a new project.
All I can remember about it is that it looked something like this:
public static Create<T>() *something missing here* : *Something missing here*
{
// add methods etc here. I also think I remember something like " Activator.CreateInstance" being used. But I'm not sure.
}
Has anybody written code like this before? Basically what it did was it created a control and passed it back to another project.
Thank you
jt
Why the following code prints "0-100"?
(function () {
for ( var i = 100; i >= 0; i -= 5) {
(function() {
var pos = i;
setTimeout(function() {
console.log(" pos = " + pos);
}, (pos + 1)*10);
})();
}
})();
I declare pos = i , which should be in a descending order. This code originated from John Resig' fadeIn() function in his book Pro javascript techniques.
Trying to use regex refind tag to find the content within the brackets in this example using coldfusion
joe smith <[email protected]>
The resulting text should be
[email protected]
Not having any luck. Any suggestions?
Hi,
When creating a branch, what are the implications of selecting the following?
Create copy in the repository from:
HEAD revision in the repository
Specific revision the repository
Working copy
Hi. Please see my code below.
ifstream myLibFile ("libs//%s" , line); // Compile failed here ???
I want to combine the path string and open the related file again.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("libs//Config.txt");
// There are several file names listed in the COnfig.txt file line by line.
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
// Read details lib files based on the each line file name.
string libFileLine;
ifstream myLibFile ("libs//%s" , line); // Compile failed here ???
if (myLibFile.is_open())
{
while (! myLibFile.eof() )
{
print "success";
}
myLibFile.close();
}
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
how can i create method which return sqrt of given nunber? for example sqrt(16) returns 4
and sqrt(5) returns 2.3... please help i am using java and know Math.sqrt() API function but i need method itself
During a recent job interview, I was asked to give a solution to the following problem:
Given a string s (without spaces) and a dictionary, return the words in the dictionary that compose the string.
For example, s= peachpie, dic= {peach, pie}, result={peach, pie}.
I will ask the the decision variation of this problem:
if s can be composed of words in the
dictionary return yes, otherwise
return no.
My solution to this was in backtracking (written in Java)
public static boolean words(String s, Set<String> dictionary)
{
if ("".equals(s))
return true;
for (int i=0; i <= s.length(); i++)
{
String pre = prefix(s,i); // returns s[0..i-1]
String suf = suffix(s,i); // returns s[i..s.len]
if (dictionary.contains(pre) && words(suf, dictionary))
return true;
}
return false;
}
public static void main(String[] args) {
Set<String> dic = new HashSet<String>();
dic.add("peach");
dic.add("pie");
dic.add("1");
System.out.println(words("peachpie1", dic)); // true
System.out.println(words("peachpie2", dic)); // false
}
What is the time complexity of this solution?
I'm calling recursively in the for loop, but only for the prefix's that are in the dictionary.
Any idea's?
Masters of regular expressions, please help!
See this string:
$string = "http://www.url.com/?fieldA=123&fieldB=456&fieldC=789";
Assuming "fieldB" always has a positive non-decimal numerical value (but not necessarily three digits long), what preg_replace command do I need to remove it completely, such that the string will then read:
$string = "http://www.url.com/?fieldA=123&fieldC=789";
Thanks!
i am using excel to connect to a mysql database
i am doing this:
rs.Find "rowid='105'"
If Not rs.EOF Then cn.Execute "delete from batchinfo where rowid='105'"
and it works well
however, i need to be able to match data on multiple columns for example like this:
rs. find "rowid='105'" and "something='sometext'" and "somethingelse='moretext'"
i need to know whether or not rs.find matched ALL of the data.
how can i do this?
according to this i can't:
http://articles.techrepublic.com.com/5100-10878_11-1045830.html#
however perhaps there's a way i can rs.execute "some select statement"
can someone help with this?
would this do the trick for me and then i would check EOF:
rs.Filter "LastName='Adams' and FirstName='Lamont'"
Want to verify that my understanding of how this works.
Have an unmanaged C++ Class with one public instance variable:
char* character_encoding;
and whose only constructor is defined as:
TF_StringList(const char* encoding = "cp_1252");
when I use this class in either managed or unmanaged C++, the first thing I do is declare a pointer to an object of this class:
const TF_StringList * categories;
Then later I instantiate it:
categories = new TF_StringList();
this gives me a pointer to an object of type TF_StringList whose variable character_encoding is set to "cp_1252";
So, is all that logic valid?
Jim
Hello everyone-
In my C# Console App I'm trying to use Regex to search a string to determine if there is a match or not. Below is my code but it is not quite working right so I will explain further. sSearchString is set to "_One-Call_Pipeline_Locations" and pDS.Name is a filename it is searching against. Using the code below it is set to true for Nevada_One-Call_Pipeline_Locations and Nevada_One-Call_Pipeline_LocationsMAXIMUM. There should be a match for Nevada_One-Call_Pipeline_Locations But Not for Nevada_One-Call_Pipeline_LocationsMAXIMUM. How can I change my code to do this properly?
Thanks in advance
if (Regex.IsMatch(pDS.Name, sSearchString))
The problem in this code is that when it's run and I push "Yes" button, This is shown:
This means that my application stopped working, I just want it to end.
private void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
string message = "An unhandled exception has ocurred, do you want close the app?";
MessageBoxResult currentMB = MessageBox.Show(message, "SomeTitleApp", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
if (currentMB == MessageBoxResult.Yes)
{ Application.Current.Shutdown(); }
else
{ e.Handled = true; }
}
I'm running PHP 5.3.0. I've found that the curly string syntax only works when the first character of the expression is $. Is there a way to include other types of expressions (function calls, etc)?
Trivial example:
<?php
$x = '05';
echo "{$x}"; // works as expected
echo "{intval($x)}"; // hoped for "5", got "{intval(05)}"
i've only ever created external .as files that extended a class such as sprite. now i just want to create one that doesn't extend anything and call it from a frame script.
package
{
public class Test
{
public function Test(val:Number, max:Number)
{
trace(val, max);
}
}
}
from my frame script of an .fla that is in the same folder as Test.as, i'll write this:
Test(50, 100);
this produces the following error:
1137: Incorrect number of arguments. Expected no more than 1.
Hi everyone...
I'm doing some research on Simple Look Up Tables.
I have :
been thru wikipedia.
Googled Look-up tables
Browsed thedailywtf.com
Been thru several websites illustrating/documenting look-up table code.
Currently i am looking for any insight anyone can throw on the topic (LuTs).
Also, I am specifically looking for any anecdotes one would like to share (again on LuTs).
All content will be adequately acknowledge (or anonymised, if requested) in the article.
Thank You
Hi
in mysql how to write a sql like this, to get the amount of X 20 and <20
select date, numberOfXMoreThan20,numberOfXLessThan20, otherValues
from table
group by (date, X20 and X<20)
thanks
I have read most of the posts on here regarding floating point, and I understand the basic underlying issue that using IEEE 754 (and just by the nature of storing numbers in binary) certain fractions cannot be represented. I am trying to figure out the following: If both Python and JavaScript use the IEEE 754 standard, why is it that executing the following in Python
.1 + .1
Results in
0.20000000000000001 (which is to be expected)
Where as in Javascript (in at least Chrome and Firefox) the answer is .2
However performing
.1 + .2
In both languages results in
0.30000000000000004
In addition, executing
var a = 0.3; in JavaScript and printing a results in
0.3
Where as doing a = 0.3 in Python results in 0.29999999999999999
I would like to understand the reason for this difference in behavior.
In addition, many of the posts on OS link to a JavaScript port of Java's BigDecimal, but the link is dead. Does anyone have a copy?
Can anyone tell me why the output of this class is 'xa'?
why the other exception won't be caught?
public class Tree {
public static void main(String... args){
try
{
throw new NullPointerException(new Exception().toString());
} catch (NullPointerException e)
{
System.out.print("x");
}
catch (RuntimeException e)
{
System.out.print("y");
}
catch (Exception e)
{
System.out.print("z");
}
finally{System.out.println("a");}
}
}
I'm working with twitter's api, trying to get the json data from
http://search.twitter.com/trends/current.json
which looks like:
{"as_of":1268069036,"trends":{"2010-03-08 17:23:56":[{"name":"Happy Women's Day","query":"\"Happy Women's Day\" OR \"Women's Day\""},{"name":"#MusicMonday","query":"#MusicMonday"},{"name":"#MM","query":"#MM"},{"name":"Oscars","query":"Oscars OR #oscars"},{"name":"#nooffense","query":"#nooffense"},{"name":"Hurt Locker","query":"\"Hurt Locker\""},{"name":"Justin Bieber","query":"\"Justin Bieber\""},{"name":"Cmon","query":"Cmon"},{"name":"My World 2","query":"\"My World 2\""},{"name":"Sandra Bullock","query":"\"Sandra Bullock\""}]}}
My structs look like:
type trend struct {
name string
query string
}
type trends struct {
id string
arr_of_trends []trend
}
type Trending struct {
as_of string
trends_obj trends
}
and then I parse the JSON into a variable of type Trending. I'm very new to JSON so my main concern is making sure I've have the data structure correctly setup to hold the returned json data.
I'm writing this in 'Go' for a project for school. (This is not part of a particular assignment, just something I'm demo-ing for a presentation on the language)
public static void main(String[] args)
{
int [][]shatner = new int[1][1];
int []rat = new int[4];
shatner[0] = rat;
System.out.println(shatner[0][3]);
}
surprised, The answer is 0, Java doesn't check this kind of indexOutOfBound error?
How do I split the UIPicker into multiple parts, like the date picker only not the Day, month, and year - my own specified variables such as - Gender and age?
I've an access database table with 3 fields :
Purchase date
Warranty time
Warranty expiry
Warranty time has 1, 2, 3, 4, 5 in it which corresponds to years.
How can I auto-populate the 'Warranty expiry' field (which is a date field) by looking at the 'Purchase date' and then adding on the 'Warranty time' (warranty time will be 1 = 365 days, 2 = 730 days, etc)?
Hi, I have the following Domain Class:
class Metric {
String name
float value
static belongsTo = [Person,Corporation]
static indexes = {
name()
}
}
How can I add a constraint so Person,Corporation and name are unique ?
Thanks.