• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:24
CET 15:24
KST 23:24
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down20ISSL (IntoTheTV x SOOP SC2 League): Premier6Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League92
StarCraft 2
General
Weekly Cups (October 19-25): Clem triples first in 5.0.17 No more SC2 streamers on team liquid? How do you feel about the mass reverts in the 5.0.17 PTR? Evil Geniuses - shutting down REPORT: StarCraft 2: Remastered In Development
Tourneys
ISSL (IntoTheTV x SOOP SC2 League): Premier Stellar Fest TWO the Moon (Dec 16-20) RSL 2026 Offline Finals LCQ Sign-Ups Sparkling Tuna Cup - Weekly Open Tournament 2026 KungFu Cup Announcement
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
Simple Questions/Answers [G] How to playtest arcade maps [A] Nemrods 1/4 players
External Content
Mutation # 549 Endless Sparkles The PondCast: SC2 News & Results Mutation # 548 Shining Bright Mutation # 547 Temple Of Terror
Brood War
General
Rollback Netcode in Brood War BW General Discussion SCHNAIL now supports Remastered [Megathread] Daily Funny Videos SC4ALL II Brood War Complete Invited Player Lineup
Tourneys
[Megathread] Daily Proleagues [Women's StarCraft] MonstarZ vs BA 2026-10-30 Star Con San Diego 2026 Small VOD Thread 2.0
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Mobile Legends: Bang Bang Armies of Exigo - YesYes? General RTS Discussion Thread
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread European Politico-economics QA Mega-thread R I P Patrick Stewart Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
TeamLiquid Health and Fitness Initiative For 2023 Football (Soccer) Thread MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8196 users

The Big Programming Thread - Page 435

Forum Index > General Forum
Post a Reply
Prev 1 433 434 435 436 437 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
Last Edited: 2014-01-27 05:34:03
January 27 2014 05:27 GMT
#8681
hi. i have a small image that i want as background like a repeating tile. how do i achieve this in css?

+ Show Spoiler +
[image loading]


edit: im dumb. its background-repeat
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2014-01-27 12:24:23
January 27 2014 12:21 GMT
#8682
On January 27 2014 13:47 WarSame wrote:
Hey everyone, could someone point me to a good guide on the basics of Java sounds? I want to make a program that is a simple timer that beeps at the end. However, none of the guides I have found online have been near useful. In particular, the current one works according to Eclipse, but when it tries to load the file in as an AudioInputStream it has a heart attack and dies. So any help/pointers on getting started would be nice. For example, if someone has done this in the past if you could just post the basic code of how to get a sound playing from on file that would make me a happy coder. Thanks.

Here is what I have so far:

   public Timer() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Test Sound Clip");
this.setSize(300, 200);
this.setVisible(true);

try {
// Open an audio input stream.
String urlLocation = System.getProperty("user.home") + "\\workspace\\GraemeTimer\\src\\htogether.mid";
System.out.println(urlLocation);
URL url = this.getClass().getClassLoader().getResource(urlLocation);
System.out.println(url);
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
// Get a sound clip resource.
Clip clip = AudioSystem.getClip();
// Open audio clip and load samples from the audio input stream.
clip.open(audioIn);
clip.start();
}
catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}


It points out a Null pointer exception from the variable url(which I've printed separately and it seems to actually be null). However, every post I've seen elsewhere online has it like this, and I actually got this code from somewhere else, so I'm pretty confused about what went wrong. It's likely something with the file location but I print that as well and it looks fine. So I'm scratching my head.


I don't know anything about java audio, but luckily I don't think that's your problem.

You are trying to load a classpath resource with a file path, which isn't the same thing. You either need to switch over to learning how loading resources from a classloader works, or just use the file based method on AudioSystem.

File based:

String fileLocation = System.getProperty("user.home") + "\\workspace\\GraemeTimer\\src\\htogether.mid";
AudioInputStream audioIn = AudioSystem.getAudioInputStream(new File(fileLocation));


I can't see your classpath, but I would guess if your .mid file is in your java path, you could just do


URL url = this.getClass().getClassLoader().getResource("htogether.mid");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
actionbastrd
Profile Blog Joined September 2010
Congo598 Posts
January 27 2014 12:28 GMT
#8683
So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less,

Prompt the user and accept the following types of values from a SINGLE input line: char float int char.

What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D:

This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything!

+ Show Spoiler +

char f, g;
int h;
float i;

printf("Enter a char, float, int, char; with no spaces in between each input: ");

scanf("%c%f%d%c", &f, &i, &h, &g);

printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g);
It rained today inside my head...
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
January 27 2014 12:32 GMT
#8684
On January 27 2014 21:28 actionbastrd wrote:
So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less,

Prompt the user and accept the following types of values from a SINGLE input line: char float int char.

What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D:

This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything!

+ Show Spoiler +

char f, g;
int h;
float i;

printf("Enter a char, float, int, char; with no spaces in between each input: ");

scanf("%c%f%d%c", &f, &i, &h, &g);

printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g);

You could just write a loop and use getchar, parse the input yourself. Scanf is kind of dangerous to use anyway because it's fairly weak against buffer overflow exploits (not that you should worry about such things when you're beginning, but still). Writing your own parser will probably teach you a lot more than just learning the format of scanf.
WarSame
Profile Blog Joined February 2010
Canada1950 Posts
January 28 2014 01:25 GMT
#8685
On January 27 2014 21:21 berated- wrote:
Show nested quote +
On January 27 2014 13:47 WarSame wrote:
Hey everyone, could someone point me to a good guide on the basics of Java sounds? I want to make a program that is a simple timer that beeps at the end. However, none of the guides I have found online have been near useful. In particular, the current one works according to Eclipse, but when it tries to load the file in as an AudioInputStream it has a heart attack and dies. So any help/pointers on getting started would be nice. For example, if someone has done this in the past if you could just post the basic code of how to get a sound playing from on file that would make me a happy coder. Thanks.

Here is what I have so far:

   public Timer() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Test Sound Clip");
this.setSize(300, 200);
this.setVisible(true);

try {
// Open an audio input stream.
String urlLocation = System.getProperty("user.home") + "\\workspace\\GraemeTimer\\src\\htogether.mid";
System.out.println(urlLocation);
URL url = this.getClass().getClassLoader().getResource(urlLocation);
System.out.println(url);
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
// Get a sound clip resource.
Clip clip = AudioSystem.getClip();
// Open audio clip and load samples from the audio input stream.
clip.open(audioIn);
clip.start();
}
catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}


It points out a Null pointer exception from the variable url(which I've printed separately and it seems to actually be null). However, every post I've seen elsewhere online has it like this, and I actually got this code from somewhere else, so I'm pretty confused about what went wrong. It's likely something with the file location but I print that as well and it looks fine. So I'm scratching my head.


I don't know anything about java audio, but luckily I don't think that's your problem.

You are trying to load a classpath resource with a file path, which isn't the same thing. You either need to switch over to learning how loading resources from a classloader works, or just use the file based method on AudioSystem.

File based:

String fileLocation = System.getProperty("user.home") + "\\workspace\\GraemeTimer\\src\\htogether.mid";
AudioInputStream audioIn = AudioSystem.getAudioInputStream(new File(fileLocation));


I can't see your classpath, but I would guess if your .mid file is in your java path, you could just do


URL url = this.getClass().getClassLoader().getResource("htogether.mid");
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);

It works. Thanks a lot!
Can it be I stayed away too long? Did you miss these rhymes while I was gone?
phar
Profile Joined August 2011
United States1080 Posts
January 28 2014 03:21 GMT
#8686
On January 27 2014 21:32 Tobberoth wrote:
Show nested quote +
On January 27 2014 21:28 actionbastrd wrote:
So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less,

Prompt the user and accept the following types of values from a SINGLE input line: char float int char.

What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D:

This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything!

+ Show Spoiler +

char f, g;
int h;
float i;

printf("Enter a char, float, int, char; with no spaces in between each input: ");

scanf("%c%f%d%c", &f, &i, &h, &g);

printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g);

You could just write a loop and use getchar, parse the input yourself. Scanf is kind of dangerous to use anyway because it's fairly weak against buffer overflow exploits (not that you should worry about such things when you're beginning, but still). Writing your own parser will probably teach you a lot more than just learning the format of scanf.

Scanf is technically safe if you are careful about how you construct your calls to it. In particular, never use %s, always use %99s (for example, if putting into a char[] of 100). But that gets annoying in many situations, so fgets, getchar, etc etc may be nicer.

Also check the return value! Good habit to get into.
Who after all is today speaking about the destruction of the Armenians?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
January 28 2014 05:35 GMT
#8687
writing an operating system on an arm board... oh god the void*
There is no one like you in the universe.
Garfailed
Profile Joined May 2011
Netherlands409 Posts
January 28 2014 06:22 GMT
#8688
On January 26 2014 22:07 Manit0u wrote:
Show nested quote +
On January 26 2014 15:53 Housemd wrote:
Update on Program:

int array [] = {15, 26, 27, 74, 65, 36, 73, 46, 73, 29, 30};
Scanner scan = new Scanner (System.in);
boolean x = true;
System.out.print("Please input a number");
int SearchValue = scan.nextInt();
for (int i = 0; i < array.length; i++){
if (x == true){
SearchValue = array [i];
break;
}
}
if (x){
System.out.println("Found");
}
else
{
System.out.println("Not Found");
}
}
}


Works perfectly fine for values that are in the array. For values that are not, it still prints out found. I believe that I have a small syntax error (in the last if-else statement?) but I cannot spot it. I tried to use Chocolate's suggestions of booleans and it looks promising.


Why use for loop here instead of foreach?


Scanner in = new Scanner (System.in);
int SearchValue = in.nextlnt();
int arr[] = { 1, 2, 3, 4, 5 };

System.out.print("Please input a number: ");

for (int n: arr)
{
if (n == SearchValue)
{
System.out.println("Found");
}
else
{
System.out.println("Not found");
}
}


Instead of printing at every index of the array, you could have a boolean. Set it to false before you loop, and if (n == searchvalue) set it to true, then at the end check if (found) is true or false and print accordingly
nunez
Profile Blog Joined February 2011
Norway4003 Posts
January 28 2014 06:24 GMT
#8689
On January 28 2014 14:35 Blisse wrote:
writing an operating system on an arm board... oh god the void*

ah sweet! more descriptive please!
conspired against by a confederacy of dunces.
Badboyrune
Profile Blog Joined May 2010
Sweden2247 Posts
January 29 2014 00:01 GMT
#8690
Ok I'm getting quite confused. I'm making a pretty basic android app, it's my first so my experience is very limited. It basically displays data from a database based on intent sent from the intent sent from another activity in the app. This all worked fine, I could navigate without any issue with the android OS back button.

However when I enable "getActionBar().setDisplayHomeAsUpEnabled(true);" and try to navigate backwards with the Home button that breaks any activity that relies on receiving an intent, because it doesn't receive any. I tried putting the information in the onSaveInstanceState bundle, but the activity does not receive the bundle when navigated to with the Home button (savedInstanceState != null returns false).

I've looked through all I've been able to find online (which has been limited because searches involving android home button are generally unhelpful) and all I've really been able to find is that the home button seems to not be programmable anymore, it either sends you to the app home activity, or the activities parent activity which is what I'm trying to achieve. I'm assuming there's some way of doing this so any help would be much appreciated.
"If yellow does start SC2, I should start handsomenerd diaper busniess and become a rich man" - John the Translator
Manit0u
Profile Blog Joined August 2004
Poland17865 Posts
Last Edited: 2014-01-29 01:45:57
January 29 2014 01:30 GMT
#8691
On January 27 2014 21:32 Tobberoth wrote:
Show nested quote +
On January 27 2014 21:28 actionbastrd wrote:
So i am trying to learn C programing, and am hoping to dive really deep into it. I have a task which i am having trouble with. I feel like accomplishing this task could be done way better, but none the less,

Prompt the user and accept the following types of values from a SINGLE input line: char float int char.

What i have is this(spoiler), which works when the question asked is "char int char float", but breaks, i am assuming because it cannot tell when the float number ends. I understand spacing is an issue to and i commented on that in the prompt,.. but i need a separator somehow, i am learning out of books and having come across anything. I personally would just have it ask in separate lines or something. D:

This is actually my first language and am really stoked on it, but its mostly a grind with little to no in person help lol. If anyone has good C programming resources i could check out and read that would be awesome too, about anything!

+ Show Spoiler +

char f, g;
int h;
float i;

printf("Enter a char, float, int, char; with no spaces in between each input: ");

scanf("%c%f%d%c", &f, &i, &h, &g);

printf("You entered: %c, %.3f, %d, %c.\n", f, i, h, g);

You could just write a loop and use getchar, parse the input yourself. Scanf is kind of dangerous to use anyway because it's fairly weak against buffer overflow exploits (not that you should worry about such things when you're beginning, but still). Writing your own parser will probably teach you a lot more than just learning the format of scanf.


When dealing with different data types in input you want to be using sscanf instead of scanf in C:

http://forum.codecall.net/topic/73122-on-using-sscanf/
http://en.cppreference.com/w/c/io/fscanf (at the very bottom here you have an example similar to what you're trying to do)

There you go:

// sample string to parse with sscanf()
char input[] = "25 54.32E-1 Thompson 56789 0123 56ß水";
/* parse as follows:
an integer, a floating-point value, a word,
two-digit integer (digits 5 and 6)
a floating-point value (digits 7, 8, 9)
an integer which isn't stored anywhere
a string of integers (digits 5 and 6)
two wide characters, using multibyte to wide conversion */

int i, j;
float x, y;
char str1[10], str2[4];
wchar_t warr[2];
setlocale(LC_ALL, "en_US.utf8");

int ret = sscanf(input, "%d%f%9s%2d%f%*d %3[0-9]%2lc",
&i, &x, str1, &j, &y, str2, warr);

printf("Converted %d fields:\ni = %d\nx = %f\nstr1 = %s\n"
"j = %d\ny = %f\nstr2 = %s\n"
"warr[0] = U+%x warr[1] = U+%x\n",
ret, i, x, str1, j, y, str2, warr[0], warr[1]);


Edit: A bonus with using sscanf is also that it doesn't matter if someone will enter the input with or without spaces. It doesn't matter.
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
January 29 2014 03:00 GMT
#8692
On January 29 2014 09:01 Badboyrune wrote:
Ok I'm getting quite confused. I'm making a pretty basic android app, it's my first so my experience is very limited. It basically displays data from a database based on intent sent from the intent sent from another activity in the app. This all worked fine, I could navigate without any issue with the android OS back button.

However when I enable "getActionBar().setDisplayHomeAsUpEnabled(true);" and try to navigate backwards with the Home button that breaks any activity that relies on receiving an intent, because it doesn't receive any. I tried putting the information in the onSaveInstanceState bundle, but the activity does not receive the bundle when navigated to with the Home button (savedInstanceState != null returns false).

I've looked through all I've been able to find online (which has been limited because searches involving android home button are generally unhelpful) and all I've really been able to find is that the home button seems to not be programmable anymore, it either sends you to the app home activity, or the activities parent activity which is what I'm trying to achieve. I'm assuming there's some way of doing this so any help would be much appreciated.


I'm also just now learning android, maybe we can struggle through this together...

Have you read this page?
OsaX Nymloth
Profile Joined March 2013
Poland3244 Posts
January 29 2014 04:41 GMT
#8693
Anyone having some experience with Drupal? I'm trying to figure out the contextual fields and relationships in Views - but together with Node Reference module. I think I have some understanding of it, but somehow I can't get it to work as I need. Probably I'm missing something obvious or just misunderstanding how it works.
Twitter: @osaxnymloth
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
January 29 2014 05:59 GMT
#8694
okay. I have a normal web html. it has 4 columns(swimlanes).
now if I open it in a tablet like ipad, when it in landscape, it must show the 4 swimlanes.
if it changes to portrait, it must change into an accordion (http://jqueryui.com/accordion/)

how do I do this? media queries? do I make two types of html?
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
OsaX Nymloth
Profile Joined March 2013
Poland3244 Posts
January 29 2014 06:49 GMT
#8695
You can use media querries in CSS just fine I guess. At last that would be the way I would try.
Here's some examples: http://css-tricks.com/css-media-queries/
Twitter: @osaxnymloth
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-01-29 15:58:26
January 29 2014 15:51 GMT
#8696
I have a question about constants (in Java if it matters).

Example:

public class Example {
private static final String TEST = "Test";

public String getTest() {
return TEST;
}
}



public class Example2 {
public static final String TEST = "Test";
}


So which is better to use - Example.getTest() or Example2.TEST? In other words, when you want to access a constant variable, do you do it from a getter method or direct variable access? I understand it's up to 'private' or 'public' but what's the decision making anyway? Is it just encapsulation (hiding implementation)? What if the method was static, then no instance is required, so would you still use a getter method over direct access to the variable?
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
January 29 2014 17:31 GMT
#8697
On January 30 2014 00:51 darkness wrote:
I have a question about constants (in Java if it matters).

Example:

public class Example {
private static final String TEST = "Test";

public String getTest() {
return TEST;
}
}



public class Example2 {
public static final String TEST = "Test";
}


So which is better to use - Example.getTest() or Example2.TEST? In other words, when you want to access a constant variable, do you do it from a getter method or direct variable access? I understand it's up to 'private' or 'public' but what's the decision making anyway? Is it just encapsulation (hiding implementation)? What if the method was static, then no instance is required, so would you still use a getter method over direct access to the variable?

It depends. Since it's a constant, there's little reason to hide it, but it could be that you want to change how it's handled later, which a getter allows without editing the interface.

This is why properties own, gives you the best of both worlds.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
January 29 2014 17:50 GMT
#8698
Do you mean properties from Objective-C?
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
January 29 2014 19:00 GMT
#8699
On January 30 2014 02:50 darkness wrote:
Do you mean properties from Objective-C?

I was specifically talking about C#, but there's similar concepts in tons of languages.
misirlou
Profile Joined June 2010
Portugal3319 Posts
January 29 2014 20:18 GMT
#8700
On January 30 2014 02:31 Tobberoth wrote:
Show nested quote +
On January 30 2014 00:51 darkness wrote:
I have a question about constants (in Java if it matters).

Example:

public class Example {
private static final String TEST = "Test";

public String getTest() {
return TEST;
}
}



public class Example2 {
public static final String TEST = "Test";
}


So which is better to use - Example.getTest() or Example2.TEST? In other words, when you want to access a constant variable, do you do it from a getter method or direct variable access? I understand it's up to 'private' or 'public' but what's the decision making anyway? Is it just encapsulation (hiding implementation)? What if the method was static, then no instance is required, so would you still use a getter method over direct access to the variable?

It depends. Since it's a constant, there's little reason to hide it, but it could be that you want to change how it's handled later, which a getter allows without editing the interface.

This is why properties own, gives you the best of both worlds.


Adding to this: To access 1st example you have to create an instance of Example to access a static constant which doesnt make much sense
Example ex1=new Example();
String s=ex1.getTest();


The getter is a good idea indeed to change how the value is handled but it makes a lot more sense if it was a static getter since it's for a static field.
Prev 1 433 434 435 436 437 1032 Next
Please log in or register to reply.
Live Events Refresh
Epic.LAN
22:00
Epic.LAN 49 Group Stage
Liquipedia
GSL
21:00
GSL CK 6
IntoTheiNu 891
SHIN 118
CranKy Ducklings SOOP81
Maru 67
Zoun (SOOP) 58
herO (SOOP) 46
Solar (SOOP)41
ByuN (SOOP) 30
Rogue 24
Rex18
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko539
LamboSC2 198
MaxPax 153
SHIN 118
Maru 67
Zoun (SOOP) 58
herO (SOOP) 46
Solar (SOOP) 41
ByuN (SOOP) 30
Rogue 24
Rex 18
StarCraft: Brood War
Jaedong 2048
Horang2 991
EffOrt 680
Light 590
BeSt 423
FanTaSy 409
Soma 335
ggaemo 290
Snow 272
Mini 261
[ Show more ]
Rush 209
actioN 190
ZerO 172
Hyuk 156
Mind 116
Barracks 83
hero 80
Hyun 79
Classic 52
Yoon 51
Mong 41
sSak 36
ToSsGirL 36
Aegong 33
Shinee 33
910 30
HiyA 26
Terrorterran 24
Sharp 19
soO 19
JYJ 17
Rock 15
Bishop 15
Creator 15
zelot 13
Trap 12
Noble 11
Icarus 5
Dota 2
Gorgc19781
qojqva876
syndereN270
Fuzer 171
League of Legends
Reynor80
Counter-Strike
kRYSTAL_60
Other Games
singsing1868
olofmeister1267
B2W.Neo1020
hiko964
Mlord564
Liquid`RaSZi339
crisheroes237
DeMusliM229
ArmadaUGS132
KnowMe79
Liquid`VortiX72
QueenE35
Hui .14
ZerO(Twitch)14
Organizations
Counter-Strike
PGL20729
StarCraft: Brood War
lovetv 6
[ Show 10 non-featured ]
StarCraft 2
• StrangeGG 45
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• HerbMon 22
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Big Brain Bouts
2h 37m
OSC
7h 37m
Replay Cast
8h 37m
Sparkling Tuna Cup
19h 37m
WardiTV Invitational
21h 37m
Epic.LAN
22h 37m
IPSL
1d 1h
eOnzErG vs McRibbed
LancerX vs StRyKeR
AI Arena Tournament
1d 3h
OSC
1d 23h
Yamato Cup
2 days
[ Show More ]
IPSL
2 days
Artosis vs RiceHat
Kyrie vs Sony
Map Test Tournament
2 days
WardiTV Weekly
2 days
Ultimate Battle
2 days
Rush vs BeSt
Replay Cast
3 days
Rogue vs Classic
Patches Events
3 days
PiGosaur Cup
4 days
Kung Fu Cup
4 days
The PondCast
5 days
KCM Race Survival
5 days
Liquipedia Results

Completed

Proleague 2026-10-28
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

IPSL Winter 2026-27
1xBet Invitational
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.