methods

Check if method exists

房东的猫 提交于 2019-12-25 16:04:07
问题 I want to check if the method Camera.Parameters.getHorizontalViewAngle() exists on the device (it's only available from API 8 and my min SDK API is 7). I tried to use "reflection", as explained here, but it catches an error saying the number of arguments is wrong: java.lang.IllegalArgumentException: wrong number of arguments Anybody could help? Camera camera; camera = Camera.open(); Parameters params = camera.getParameters(); Method m = Camera.Parameters.class.getMethod(

get Hashmap from Method

北战南征 提交于 2019-12-25 14:26:44
问题 I'm new to Java and haven't yet learned how to create 2 separate classes and combine them and so, I end up jumbling everything in the main and you can imagine how the code end up looking not understandable, which I plan to learn later on in my course. Yet I need a solution to work with 'Methods' so my code can look cleaner and if I need to add to it or repair it wouldn't be much of a hassle. So basically my question is whether I can use Hashmap.get from the main to get information from a

How do I use a method I have made? JAVA

感情迁移 提交于 2019-12-25 14:00:15
问题 I have created this method to find the discrimiant using the function b^2-4ac public class Discriminant { public double Disc (double a, double b, double c){ double disc; disc = Math.pow(b, 2) - 4*a*c; return disc ; } } Then i made another method to find all positive roots of a function public class PlusRoot { public double plusRoot (double a, double b, double c){ double proot; proot = -b + Math.sqrt(disc)/ 2*a; return proot; } } But it is not working because it says disc cannot be resolved as

Why can you call a private method from outside of the object scope?

人盡茶涼 提交于 2019-12-25 10:23:54
问题 I am curious as to why this is allowed to work, whereby you can call and successfully execute a private method on an object from outside of the object scope providing you are making the call from a class of the same type. The private method call from a public scope to me seems not to satisfy the criteria of a private method, so why is this allowed in both PHP and Java? <?php class A { public function publicMethod () { $obj = new static; $obj->privateMethod (); } private function privateMethod

Why methods don't work?

扶醉桌前 提交于 2019-12-25 10:00:19
问题 I'm programming a calculator and when I choose for example first option, program stops. I can't enter any numbers. What do I have to change in my code to make the methods work? I don't know what I have to do. main.cpp: #include "stdafx.h" #include <iostream> #include "Calculator.h" using namespace std; float Calculator::add() { cout << "Enter 1 number: "; cin >> a; cout << "Enter 2 number: "; cin >> b; system("cls"); cout << a + b << endl; return 0; } float Calculator::sub() { cout << "Enter

Why methods don't work?

北城以北 提交于 2019-12-25 10:00:03
问题 I'm programming a calculator and when I choose for example first option, program stops. I can't enter any numbers. What do I have to change in my code to make the methods work? I don't know what I have to do. main.cpp: #include "stdafx.h" #include <iostream> #include "Calculator.h" using namespace std; float Calculator::add() { cout << "Enter 1 number: "; cin >> a; cout << "Enter 2 number: "; cin >> b; system("cls"); cout << a + b << endl; return 0; } float Calculator::sub() { cout << "Enter

Objective C scope problem

送分小仙女□ 提交于 2019-12-25 09:18:11
问题 I have the following Obj C function that works properly: NSString* myfunc( int x ) { NSString *myString = @"MYDATA"; return myString; } However if I add code to update a UIImage the compile fails with image1 being unknown. image1 is valid: it's set up in the .h, synthesized and that exact line of code works in a method below this function. Only when I move the line of code up to this function does it fail. NSString* myfunc( int x ) { NSString *myString = @"MYDATA"; image1.image = [UIImage

Issue with Ruby decryption method

谁都会走 提交于 2019-12-25 08:55:59
问题 I'm trying to figure out why my Ruby decryption method seems to break only for certain letters of the alphabet. The goal of the method is to take an input string ("new_str") and decrypts it by rewriting EACH letter in the string with its predecessor in the alphabet. i.e. "bcd" should return "abc" ... I could be wrong but it seems to work for the letters a-j, but then breaks for the letters k-z... for that last set it seems to return either an "a" "b" or "z" no matter the letter: e.g. decrypt(

what do an undefined method [] mean in rails?

谁说我不能喝 提交于 2019-12-25 08:27:55
问题 I get the following error: undefined method `[]' for nil:NilClass The related snippet in line 50: 47: <%=h @contact.date_entered.to_date %></br> 48: Next event: 49: <% next_delayed_todo = @contact.next_delayed_todo %> 50: <% unless next_delayed_todo[:event].nil? %> 52: <%= next_delayed_todo[:event].title %> </br> 回答1: See how you have 3 consecutive lines of nothing but code in your view? That's a sign you should pull it out into a helper, in order to keep your views clean. New view code: <%=h

Rails 3: undefined method messages for Folder

≡放荡痞女 提交于 2019-12-25 08:04:23
问题 I'm running Rails 3 and like to have a message system. Here is the tutorial for it: http://www.novawave.net/public/rails_messaging_tutorial.html It's for Rails 2 so I was trying to implement it in Rails 3. Everything went fine and i can send messages. But when i like to check my inbox this error shows up: undefined method `messages' for #<Folder:0x0000010419fd48> Mailbox Controller: class MailboxController < ApplicationController def index redirect_to new_session_path and return unless logged