I came across this article discussing why the double-check locking paradigm is broken in java. Is the paradigm valid for .net (in particular, C#), if variables are declared volatile?
Using bash, I have a list of strings that I want to use to replace an int. Here's an example:
day1=Monday
day2=Tuesday
day3=Wednesday
day4=Thursday
day5=Friday
day6=Saturday
day7=Sunday
If I have an int, $dow, to represent the day of the week, how do I print the actual string? I tried this:
echo ${day`echo $dow`}
but get error of "bad substitution". How do I make this work? Note: I can change the $day variables to a list or something.
Hello,
I'm wondering the opinion of what is the best way to pass a lot of values between pages. I was thinking of either saving the values to a database, using context.Items[], or Session[]. I'm not sure about what is the best method. I'm passing probably around 40 variables.
How does PHP read if statements?
I have the following if statements in this order
if ( $number_of_figures_in_email < 6) {
-- cut: gives false
}
if($number_of_emails > 0) {
-- cut: gives false
}
if ( $number_of_emails == 0) {
-- cut: gives true
}
The code behaves randomly. It sometimes goes to the third if clause and gives me a success, while sometimes to the one of the first two if clauses when the input variables are constant.
This suggests me that I cannot code only with if statements.
For a few days now I'm using NetBeans 6.8 for doing PHP work.
But even if a class-file is included and the methods are public and there's phpDoc used, NetBeans everytime shows "No Suggestions" in the window.
E.g. I type
$user->
and press CTRL+Space, I do expect all the methods and variables but there aren't shown any. ideas?
I'm looking for a script/tool that can be customized to check and enforce coding/naming conventions on a C/C++ code.
It should check for example:
Code lines are wrapped at some length.
Private variables have prefix _
Code is indented properly.
All functions are documented.
Basically, I want to enter text into a text area, and then use them. For example
variable1:variable2@variable3
variable1:variable2@variable3
variable1:variable2@variable3
I know I could use explode to make each line into an array, and then use a foreach loop to use each line separately, but how would I separate the three variables to use?
Say I have the following code:
public class ClassToTest
{
AnotherClass anotherClass;
public void methodToTest( int x, int y )
{
int z = x + y
anotherClass.receiveSomething( z );
}
}
public class AnotherClass
{
public void receiveSomething( int z ) {.. do something.. }
}
I want to make assertion on the value of the variable z. How do I do this? Variables x, y, and z could be some other Java class types, and I just used "int" for simplicity.
So after a few hours of workaround the limitation of Reflection being currently disabled on the Google App Engine, I was wondering if someone could help me understand why object reflection can be a threat. Is it because I can inspect the private variables of a class or are there any other deeper reasons?
I have a class definition of the form
class X
{
public:
//class functions
private:
A_type *A;
//other class variables
};
and struct A_type is defined as
struct A_type
{
string s1,s2,s3;
};
Inside the constructor, I allocate appropriate memory for A and try A[0].s1="somestring";
It shows segmentation fault.
Is this kind of declaration invalid, or am I missing something
I just found this code on wikipedia.
Link: http://en.wikipedia.org/wiki/Sizeof#Use
The code:
/* the following code illustrates the use of sizeof
* with variables and expressions (no parentheses needed),
* and with type names (parentheses needed)
*/
char c;
printf("%zu,%zu", sizeof c, sizeof(int));
It states that: "The z prefix should be used to print it, because the actual size can differ on each architecture."
I tried it on my compiler, but it gives the following result:
'zu,zu'
I have problem that i just cant figure out right now.
I am trying to develop a Windows-8 style app and im stuck implementing this functionality.
I have a MainWindow which contains a ListBox and a Button (lets say addButton).
When i click the button i navigate to a new page, lets say AddCustomerPage with this.Frame.Navigate(typeof (AddCustomerPage));
AddCustomerPage has 1 textBox and 1 button (lets say doneButton. When i click the button i want the string in the textBox to be added to the ListBox on the previous page.
This is my current functionality:
1. MainWindow is created.
Click addButton
AddCustomer page is created. MainWindow is destroyed(problem).
Click doneButton
A MainWindow object is created with a ListBox with 1 item.
Repeat the add process, i always get a MainWindow with a ListBox with 1 item.
Thanks for the help. Here is the code:
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
this.brainPageController = new PageController();
// add items from the List<String> to the listBox
listGoals.ItemsSource = brainPageController.GetListGoals();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var parameter = e.Parameter as String;
// a simple controller that adds a string to a List<string>
brainPageController.AddGoal(parameter);
}
private void addButton_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof (GoalsInfo));
}
// VARIABLES DECLARATION
private PageController brainPageController;
}
public sealed partial class GoalsInfo : WinGoalsWIP.Common.LayoutAwarePage
{
public GoalsInfo()
{
this.InitializeComponent();
this.brainPageController = new PageController();
}
protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
{
}
protected override void SaveState(Dictionary<String, Object> pageState)
{
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
brainPageController.AddGoal(nameTextBox.Text);
this.Frame.Navigate(typeof(MainPage), nameTextBox.Text);
}
// VARIABLES DECLARATION
PageController brainPageController;
}
Hi all, need some help with this code if anyone can answer. Any suggestions are most appreciated.
I have a report that I want to save to my hard drive when clicking a button. When saving the report I want the filename to be created using two pieces of information from the report.
Variables:
Report = "Contract"
Save Location = "C:\Folder\"
File Name = [Customer] & " _ " & [Date]
File Type = PDF
Thank you!
I am using PHP/Java bridge to run PHP scripts on the Tomcat server. Can someone point me to an example as to how to call my PHP scripts from a Java file.
<?php
class X{
//variables
//functions
}
?>
Now I want to call the member functions of class X using its object via a Java file. How do I do this?
I have a form in which few details like three text fields and an image is to be uploaded, now as i submit or save the page it should be redirected to the same form storing the previous values in some variables array, I need this array so that according to the count of this array i can display the grid(listing of data) below the form on every submit..
I need to find the certain driver variables for unit sales & their impact on sales. My data is such data the error does not follow normal distribution & the unit sales is also not following any particular statistical distribution. Given such condition, it is difficult for me to use simple liner regression or GLM.
Can any of you please suggest me some non parametric regression technique which I can use in R to model the relationship?
Thanks,
This may be a completely dumb question, but I've seen a couple examples declaring the variables AFTER putting them in bind_param:
http://devzone.zend.com/article/686
I've never seen this done before and all my programming knowledge says I should define them before hand. Is this a valid/preferred way?
I'm trying to write fully automated unit tests in JavaScript and I'm looking for a way to read some private variables in various JS functions. I thought I recalled a way to inject privileged members into a function/object (and found an overwhelming occurrence of "no such thing as private in JS") and yet I can't find any resources indicating how.
I'm trying to read through the properties of .prototype but if there's a way, someone out here would know where to direct me faster than I'd find on my own.
Thanks
Hello how to use switch loop in my android project ? I want to use Android 2.1
I need JRE 1.7, but I want to use Android 2.1
I use loop like this:
switch ((CHAR[Math.abs(intGen.nextInt()%2)])) {
case "+":
result = random2 + random3;
break;
case "-":
result = random2 + random3;
break;
}
LogCat:
Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted
Input integer array:
a[8] = { a1, a2, a3, a4, b1, b2, b3, b4 }
Output array:
a[8] = { a1, b1, a2, b2, a3, b3, a4, b4 }
Forget all corner cases, make sure your solution works for any int array of size 2n. You can use one or two temp variables for looping or anything, but you shouldn't use any temp arrays/stacks/queues etc to store entire array or part of array.
I'm able to get answer in O(n*log n), but I'm looking for better solution.
I noticed that Joomla uses less secure var type for variables in classes
Why is this?
In my own components,plugins,modules should I follow this convention or use a more secure private, public and protected keywords.
I have been using this "logic" in C++ and VB with success, but am tied up in Java...
Simply put,
public void DataProviderExample(String user, String pwd, String no_of_links,
String link1, String link2, String link3) {
for (int i=1;i<=no_of_links;i++) {
String link = "link"+i;
System.out.println(link);
}
Now, if the variables link1, link2 and link3 have a value of "X", "Y" and "Z" respectively, upon running this program, I get the following output -
link1
link2
link3
What I want is -
X
Y
Z
Any ideas?