How can I get a specific value from an object?
I'm trying to get a value of an instance
for eg.
ListOfPpl newListOfPpl = new ListOfPpl(id, name, age);
Object item = newListOfPpl;
How can I get a value of name from an Object item??
Even if it is easy or does not interest you can anyone help me??
Edited: I was trying to build a binary...
Delete every 't'th (t>1) node of a single linked list. In the resultant linked list, again delete 't'th node. Repeat this till only t-1 nodes remains.
For this i have come up with:
Traverse until you reach 't'th node, delete all the nodes till the end.
Is there any efficient way other than this?. Can any one please help me out. Thanks.
...
I have array of colors:
String s[]=new String[]{"red","black..............};
The only possible colors are red and black. I need an algorithm which partitions the array such that all red come before all black. How can I compare/exchange them to accomplish that?
i have tried this
public class Partition{
public static void main(Stri...
I have to write a program in C which returns file size in blocks just like ls -s command.
Please help.
I tried using stat() function (st_blksize)...And I am unable to implement it.
My code looks like this
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
void main(int argc, char **argv)
{
DIR ...
Hi! This was a question in our old C++ exam. This code is driving me crazy, could anyone explain what it does and - especially - why?
int arr[3]={10,20,30};
int *arrp = new int;
(*(arr+1)+=3)+=5;
(arrp=&arr[0])++;
std::cout<<*arrp;
...
Hello Everyone,
Basicly, what I need for the program to do is to act a as simple fraction calculator (for addition, subtraction, multiplication and division) for the a single line of input, for example:
-input: 1/7 + 3/5
-output: 26/35
My initial code:
import sys
def euclid(numA, numB):
while numB != 0:
numRem = numA % nu...
So I've been trying to solve this assignment whole day, just can't get it.
The following function accepts 2 strings, the 2nd (not 1st) possibly containing *'s (asterisks).
An * is a replacement for a string (empty, 1 char or more), it can appear appear (only in s2) once, twice, more or not at all, it cannot be adjacent to another * (ab*...
I'm studing orders of growth "big oh", "big omega", and "big theta". Since I can't type the little symbols for these I will denote them as follows:
ORDER = big oh
OMEGA = big omega
THETA = big theta
For example I'll say n = ORDER(n^2) to mean that the function n is in the order of n^2 (n grows at most as fast n^2).
Ok for the most...
switch ( choice )
{
case '+':
System.out.printf( "The answer is: %1$.4f.\n", first + second );
break;
case '-':
System.out.printf( "The answer is: %1$.4f.\n", first - second );
break;
case '*':
System.out.printf( "The answer is: %1$.4f.\n", first * second );
...
Hi,
I have been given a task at school to write a program that
Reads three strings
Stores the third string in dynamically allocated memory
Print out the last 4 letters of the first word alphabetically.
Here is the program I have so far. The strings are all stored in different variables, making them hard to sort. If anyone could give...
The following function accepts 2 strings, the 2nd (not 1st) possibly containing *'s (asterisks).
An * is a replacement for a string (empty, 1 char or more), it can appear appear (only in s2) once, twice, more or not at all, it cannot be adjacent to another * (ab**c), no need to check that.
public static boolean samePattern(String s1, St...
I've created a scanner class to read through the text file and get the value what I'm after. Let's assume that I have a text file contains.
List of people: length 3
1 : Fnjiei : ID 7868860 : Age 18
2 : Oipuiieerb : ID 334134 : Age 39
3 : Enekaree : ID 6106274 : Age 31
I'm trying to get a name and id...
I am new to SQL and I need to build a database for a grocery store(not real, just a course assignment)
i have two fields from two different tables - supplied price - the price that the store buys from the supplier and price that is given to the customers
How can I make a constraint that insures that supplied price is lower then the pr...
Do you know any real applications for Simulated Annealing?
Simulated Annealing is a heuristic algorithm used for problems like the traveling salesman or the knapsack problem.
And yes, this is homework. I have to write a paper on this, and I thought this would be the best starting point. Perhaps someone actually works on a project that ...
I know that Little's Law states (paraphrased):
the average number of things in a system is the product of the average rate at which things leave the system and the average time each one spends in the system,
or:
n=x*(r+z);
x-throughput
r-response time
z-think time
r+z - average response time
now i have question about a problem ...
I have a struct like this:
struct db {
string name,sur;
int num;
};
And declared an array of db structs:
struct db a[10];
and every member of a[] is filled with a name, surname and a number but there can be the same number appearing multiple times.
I need to sort the numbers, and print the results, i.e. sort by the num of each s...
Write a static method in Java:
public static void sortByFour (int[] arr)
That receives as a parameter an array full of non-negative numbers (zero or positive) and sorts the array in the following way:
In the beginning of the array all the numbers that are divisible by four will appear.
After them all the numbers in the array that di...
What is the difference between Javascript and ASP.net?
...
Hi,
This is probably a stupid question, but how do I run a class file on windows 7? I usually create my own .java files and then use a basic IDE (with JDK6) to compile it to a class and run it automatically. My professor gave a .class file that we are supposed to play with extensively but I have no idea how to to run it here. Note that ...
I've got a 2-dimensional array like this (it represents a timetable):
Orange cells are lectures and whites are free time. How could I calculate number of free hours between lectures in the same day? (columns are days and rows are hours)
For example, in this table the result should be:
2 for first column
0 for second colum
--> The fun...