methods

Printing a new array of primes from a random array?

Hy there i a beginner in java started 3 weeks ago, im having some problems with this code. in the main method i have an array containing 10 elements. i've already made several methods to like public static void println(int[] array) ------ to print and array public static boolean isPrime(int el) ----------- prime test. returns tru...

Possible to return a String array

Is it possible to make a method that returns a string [ ] in java???? ...

Java using functions in a file

Ok really stupid question, but I have some methods defined in a file called x.java, which is in the default folder, and in the same folder, I have a file called z.java. I want to use the functions defined in x in z. When I try, it tells me the function is undefined. I tried to put import x.java; but it says x.java cannot be resolved. Wha...

Why isn't this compiling?

I'v created this class here: //Integer rectangle class class AguiRectangle { int x; int y; int width; int height; public: bool isEmpty { return x == 0 && y == 0 && width == 0 && height == 0; } int getTop() { return x; } int getLeft() { return y; } int ge...

Naming conventions for java methods that return boolean(No question mark)

I like using question mark at the end of method/function names in other languages. Java doesn't let me do this. As a work around, how else can I name boolean returning methods in java ? Using an 'is', 'has', 'should','can' in the front of method sound ok for some cases. Is there a better way to name such methods ? For e.g. createFreshSn...

Overriding a method in an instantiated Java object

I would like to override a method in an object that's handed to me by a factory that I have little control over. My specific problem is that I want to override the getInputStream and getOutputStream of a Socket object to perform wire logging; however the generic problem is as follows: public class Foo { public Bar doBar() { ...

How to pass method arguments to a selector

If I have a method like this: - (void) foo { } Then I can access it through a selector like this: @selector(foo) But what if I have a method like this: - (void) bar:(NSString *)str arg2:(NSString *)str2 { } Then how do I access it through a selector? ...

Functions / Methods in Objective C!

Hi guys! I need help with functions in objective C? In C++ i can make a function like this: int testFunction(int zahl) { int loop; loop = zahl * 10; return loop; } this function multiply my zahl with 10 and returns the result. In C++, i can call this function whenever i want with: testFunction(5); and it returns 50. ...

custom methods in python urllib2

Using urllib2, are we able to use a method other than 'GET' or 'POST' (when data is provided)? I dug into the library and it seems that the decision to use GET or POST is 'conveniently' tied to whether or not data is provided in the request. For example, I want to interact with a CouchDB database which requires methods such as 'DEL',...

Multiple Methods in a jQuery Event

I'm having some difficulty with writing some jQuery code. What i'm trying to do is pass multiple methods through an event handler like so $(foo).click(methodOne , methodTwo); The purpose of the first method is to fade out the current view and then hide it and the purpose of the second method is to display an alternate view. For whatever ...

Using *this in C++ class method to fully overwrite self instantiation

Is the following code safe? (I already know it compiles properly.) void Tile::clear() { *this = Tile(); } int main() { Tile mytile; mytile.clear(); } ...

ActionScript - Overriding Method Without Matching Signature?

when extending a class, is it impossible to override a method without also matching the parameters? for example, i'd like to use the method's name, in this case it's a socket extension and the method i want to override is connect. however, i want to request additional parameters that the stock connect function does not request. is the...

Populate DataTable with records from database?

This is my GET Method to get my data from my DataTable Private Function GetData() As PagedDataSource ' Declarations Dim dt As New DataTable Dim dr As DataRow Dim pg As New PagedDataSource ' Add some columns dt.Columns.Add("Column1") dt.Columns.Add("Column2") ' Add some test data For i As Integer = 0 To 10 dr = dt.NewRo...

extension method for a method C#

Hi everyone, Is there a way to have extension method on the method? Example for this would be method that takes some user object as parameter and you need to do security check if that user can use that method at the very beginning of the method. Can the method have extension method like "check can this user use me" and return bool. Th...

ruby metaprogramming - getting method names and parameter info for a class

Hi All, I want to get class methods in an object. Please see the following example I have a class "user.rb" class User def say_name end def walk(p1) end def run(p1, p2) end end and I wrote the following code require 'user.rb' a = User.new arr = a.public_methods(all = false) Above code will return the method ...

Delegates/Anonymous Method in C# 2

In C# 1. You don't have delegate sorting or comparison options. You might be forced to do it by creating another type which implements IComparer to sort your collections in ArrayList. But starting from c# 2. You can use delegates for your comparisons. Look the following example. List<Product> products = Product.GetSampleProducts(); prod...

converting Java code to Android

Hi I Have a Java application and I need to convert it to an Android application is there any resources to show how ? in Android developer site I didnt found anything like that! I need to use the Java methods and classes in android ,How it can be done? ...

Best implementation for a callback method to update multiple fields

Hey everyone, I am developing a mobile application (BlackBerry) with Java that makes use of the Google Translate API. I have it set up so that a user can specify a language before logging in, and then once they log in, I have wrappers around every piece of text displayed to screen which will translate the text based on the language cho...

How to call a selector in a different class

How would this code be different if the method was in a different class? [saveButton addTarget:self action:@selector(saveArray) forControlEvents:UIControlEventTouchUpInside]; ...

Disabling and delaying an IBAction button

I have an IBAction button that I would like to enable after a 30 second delay. the button would be in the view but disabled for 30 secs. does anyone know how I would go about doing this? here's what I have - a simple IBAction that plays some audio: -(IBAction) playSound:(id)sender { [theAudio play]; } thanks for any help. ...